Relay Compiler

Relay Compiler

Relay Modern uses the Relay Compiler to convert graphql literals into generated files that live alongside your source files.

While you type queries as:

graphql`
  fragment MyComponent on Type {
    field
  }
`

This causes a generated file to appear in ./__generated__/MyComponent.graphql, with both runtime artifacts (which help to read and write from the Relay Store) and Flow types to help you write type-safe code.

The Relay Compiler is responsible for generating code as part of a build step which, at runtime, can be used statically. By building the query ahead of time, the client's JS runtime is not responsible for generating a query string, and fields that are duplicated in the query can be merged during the build step, to improve parsing efficiency. If