Prebuilt types pre-calculate fragment and operation types at build time, replacing runtime type inference with a static type registry for faster IDE responsiveness and reliable type resolution across bundler boundaries.
When you run typegen, it scans your source files for fragment and operation definitions, computes their precise input/output types, and writes them to a types.prebuilt.ts registry. The main index.ts module automatically references this registry — no path aliases or import changes needed.
This produces the following output structure:
When codegen runs for the first time, it creates types.prebuilt.ts as an empty stub. Running typegen populates the registry with actual types. Subsequent codegen runs preserve the existing types.prebuilt.ts file.
For fragments to be included in the prebuilt registry, they must have a key property:
Tagged template syntax — the first argument to fragment() serves as the key:
The first argument to fragment() serves as the key in either syntax:
Fragments without a key property are silently skipped during prebuilt type generation. They will not appear in types.prebuilt.ts.
Operations use their name property as the key automatically — no additional configuration needed: