Fragment Matcher
Generate fragment matcher for Apollo Client. This plugin is required for using fragments with Apollo Client.
- Version
- 7.1.0
- Weekly downloads
- 850k
- License
- MIT
- Updated
- Jul 6, 2026
Installation
npm i -D @graphql-codegen/fragment-matcher
yarn add -D @graphql-codegen/fragment-matcher
pnpm add -D @graphql-codegen/fragment-matcher
bun add -D @graphql-codegen/fragment-matcher
Config API Reference
module
type: string
Compatible only with JSON extension, allow you to choose the export type, either module.exports or export default. Allowed values are: commonjs, es2015.
Default value: “es2015”
apolloClientVersion
type: number
Compatible only with TS/TSX/JS/JSX extensions, allow you to generate output based on your Apollo Client version. Note: 3 also works for version 4.
Default value: “3”
useExplicitTyping
type: boolean
Create an explicit type based on your schema. This can help IDEs autofill your fragment matcher. This is mostly useful if you do more with your fragment matcher than just pass it to an Apollo-Client. Default value: “false”
federation
type: boolean
deterministic
type: boolean
When enabled sorts the fragment types lexicographically. This is useful for deterministic output. Default value: “false”
How to use?
If you are using Apollo Client 3, update your codegen config accordingly, and then use it in your Apollo cache instance:
If you are using version 2 of Apollo-Client, you need to specify the apolloClientVersion: 2{:ts} configuration, and then use it like that: