{"owner":"ardatan","repo":"graphql-tools","hasSkills":true,"totalSkillsCount":17,"totalTokensCount":4071,"categories":["plugin-manifest"],"hasMcp":false,"mcpConfig":null,"found":["packages/documents/README.md","packages/executor/README.md","packages/graphql-tag-pluck/README.md","packages/import/README.md","packages/jest-transform/README.md","packages/links/README.md","packages/load-files/README.md","packages/load/README.md","packages/loaders/external-fragment/README.md","packages/merge/README.md","packages/mock/README.md","packages/optimize/README.md","packages/relay-operation-optimizer/README.md","packages/resolvers-composition/README.md","packages/schema/README.md","packages/webpack-loader-runtime/README.md","packages/webpack-loader/README.md"],"skills":{"packages/documents/README.md":"# `@graphql-tools/documents`\n\nUtilities for GraphQL documents.\n\n## Install\n\n```bash\nnpm install @graphql-tools/documents\n```\n\n## Contents\n\n### Print GraphQL Documents\n\nA stable way to print a GraphQL document. All executable/fragment variable definitions, fields are\nprinted in a stable way. Useful for stuff like persisted GraphQL operations.\n\n#### Usage\n\n```ts\nimport { parse } from 'graphql'\nimport { printExecutableGraphQLDocument } from '@graphql-tools/documents'\n\nconst inputDocument = parse(/* GraphQL */ `\n  query A {\n    ... on Query {\n      a {\n        ...B\n        b\n      }\n    }\n    ... on Query {\n      a {\n        ...B\n        a\n      }\n    }\n  }\n\n  fragment B on Query {\n    c\n  }\n`)\nconst outputStr = printExecutableGraphQLDocument(inputDocument)\nconsole.assert(\n  outputStr ===\n    'fragment B on Query { c } query A { ... on Query { a { a ...B } } ... on Query { a { b ...B } } }',\n  'Stuff is not equal.'\n)\n```\n\n#### Rules\n\n- Fragments are always printed before executable operations\n- Executable operations are sorted alphabetically by name.\n- Arguments (Directive, Fields) are sorted alphabetical\n- Selections sets are sorted Field, FragmentSpread, InlineFragmentSpread (sorted based on\n  TypeCondition, inner SelectionSet)\n","packages/executor/README.md":"## `@graphql-tools/executor`\n\nFork of GraphQL.js' execute function\n","packages/graphql-tag-pluck/README.md":"Check API Reference for more information about this package;\nhttps://www.graphql-tools.com/docs/api/modules/graphql_tag_pluck_src\n\nYou can also learn more about GraphQL Tag Pluck in this chapter;\nhttps://www.graphql-tools.com/docs/graphql-tag-pluck\n","packages/import/README.md":"Check API Reference for more information about this package;\nhttps://www.graphql-tools.com/docs/api/modules/import_src\n\nYou can also learn more about GraphQL Import in this chapter;\nhttps://www.graphql-tools.com/docs/schema-loading#using-import-expression\n","packages/jest-transform/README.md":"# GraphQL Jest Transform\n\nA Jest transformer to preprocess GraphQL Documents (operations, fragments and SDL)\n\n    npm install @graphql-tools/jest-transform\n\nIn your `package.json`:\n\n```json\n{\n  \"jest\": {\n    \"transform\": {\n      \"\\\\.(gql|graphql)$\": \"@graphql-tools/jest-transform\"\n    }\n  }\n}\n```\n\nor `jest.config.js`:\n\n```js\nmodule.exports = {\n  // ...\n  transform: {\n    '\\\\.(gql|graphql)$': '@graphql-tools/jest-transform'\n  }\n}\n```\n\n> How is it different from `jest-transform-graphql`? It doesn't use `graphql-tag/loader` under the\n> hood but our own, more optimized and customisable `@graphql-tools/webpack-loader`.\n\n## Options\n\n- noDescription (_default: false_) - removes descriptions\n- esModule (_default: false_) - uses import and export statements instead of CommonJS\n\n```json\n{\n  \"globals\": {\n    \"graphql\": {\n      \"noDescription\": true\n    }\n  }\n}\n```\n","packages/links/README.md":"Check API Reference for more information about this package;\nhttps://www.graphql-tools.com/docs/api/modules/links_src\n\nYou can also learn more about Apollo Links in Schema Wrapping in this chapter;\nhttps://www.graphql-tools.com/docs/remote-schemas#wrapschemaschemaconfig\n","packages/load-files/README.md":"Check API Reference for more information about this package;\nhttps://www.graphql-tools.com/docs/api/modules/load_files_src\n\nYou can also learn more about File Loading in this chapter;\nhttps://www.graphql-tools.com/docs/schema-merging#file-loading\n","packages/load/README.md":"Check API Reference for more information about this package;\nhttps://www.graphql-tools.com/docs/api/modules/load_src\n\nYou can also learn more about Apollo Links in Schema Loading in this chapter;\nhttps://www.graphql-tools.com/docs/schema-loading\n\nYou can also learn more about Apollo Links in Documents Loading in this chapter;\nhttps://www.graphql-tools.com/docs/documents-loading\n","packages/loaders/external-fragment/README.md":"# @graphql-tools/external-fragment-loader\n\nResolves missing GraphQL fragments by following direct and transitive dependencies in\n`package.json`, loading only the external fragments the package needs.\n\n## Installation\n\n```sh\nnpm install @graphql-tools/external-fragment-loader\n```\n\nThe resolver requires a target (consumer) package directory and one or more directories containing\nits dependency packages:\n\n```ts\nconst options = {\n  packageDir: '/path/to/packages/my-app',\n  externalPackagesDirs: ['/path/to/packages']\n}\n```\n\n`packageDir` and `externalPackagesDirs` should be absolute paths. By default, the loader scans `src`\ndirectory in the above packages for `.ts`, `.tsx`, `.js`, `.jsx`, `.graphql`, and `.gql` files.\nThese defaults can be changed with the options described in [`options.ts`](./src/options.ts).\n\n## Three API entry points\n\n| Entry point                | Returns                                                        | Use it when                                                                                    |\n| -------------------------- | -------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |\n| Default export             | `DocumentNode` (or `Promise<DocumentNode>` with `async: true`) | Configuring a Codegen or GraphQL Tools custom loader; uses the synchronous resolver by default |\n| `ExternalFragmentLoader`   | `Source[]` with `document`, `rawSDL`, and `location`           | Using `@graphql-tools/load` programmatically (can be async)                                    |\n| `resolveExternalFragments` | File metadata, including `filePath` and fragment definitions   | Building a file list or another custom workflow                                                |\n\nEach entry point has a synchronous variant where applicable. The async and sync variants are:\n\n- `async: true` / `async: false`\n- `ExternalFragmentLoader.load()` / `ExternalFragmentLoader.loadSync()`\n- `resolveExternalFragments()` / `resolveExternalFragmentsSync()`\n\n### 1. Default loader export (for GraphQL Code Generator)\n\nThe default export returns a single merged `DocumentNode`. This is the simplest option for GraphQL\nCode Generator because Codegen's custom-loader path expects one `DocumentNode` or one `Source`.\n\nThis is a sample of code generation for `packages/my-package`. The script runs from the monorepo\nroot.\n\n```ts\nimport { resolve } from 'node:path'\nimport type { CodegenConfig } from '@graphql-codegen/cli'\n\nconst packageDir = resolve('packages/my-package')\nconst externalPackagesDir = resolve('packages')\n\nconst config: CodegenConfig = {\n  schema: './schema.graphql',\n  documents: ['./packages/my-package/src/**/*.graphql'],\n  externalDocuments: [\n    {\n      // a pointer that triggers the custom loader for the consumer package\n      [packageDir]: {\n        loader: '@graphql-tools/external-fragment-loader',\n        packageDir,\n        externalPackagesDirs: [externalPackagesDir],\n        async: true // codegen can consume Promise<DocumentNode> directly\n      }\n    }\n  ],\n  generates: {\n    './packages/my-package/src/__generated__/types.ts': {\n      plugins: ['typescript', 'typescript-operations']\n    }\n  }\n}\n\nexport default config\n```\n\nUse at most one external-fragment pointer for each `packageDir` in a Codegen configuration. The\nloader returns all required external fragments for that package; repeating the pointer causes those\nfragments to be loaded more than once and can produce duplicate fragment definitions. Normal\ndocument pointers can still be listed alongside the single external-fragment pointer.\n\nThe default export uses the synchronous resolver unless `async: true` is set. With `async: true`, it\nreturns a `Promise<DocumentNode>` and uses the asynchronous resolver. Use this option with Codegen\nor another asynchronous loading API; omit it or set it to `false` when using `loadDocumentsSync`.\n\n### 2. Class-based loader\n\nUse `ExternalFragmentLoader` when calling `@graphql-tools/load` directly or when you need the\nindividual `Source` objects:\n\n```ts\nimport { ExternalFragmentLoader } from '@graphql-tools/external-fragment-loader'\n\nconst loader = new ExternalFragmentLoader()\n\nconst sources = await loader.load('.', {\n  packageDir,\n  externalPackagesDirs: [externalPackagesDir]\n})\n```\n\nTo register the class with `@graphql-tools/load`, pass it in the `loaders` option for the pointer\nthat represents the external-fragment document:\n\n```ts\nimport { loadDocuments } from '@graphql-tools/load'\n\nconst sources = await loadDocuments(['./external-fragments.graphql'], {\n  loaders: [loader],\n  packageDir,\n  externalPackagesDirs: [externalPackagesDir]\n})\n```\n\nThe loader also exposes a **synchronous** method:\n\n```ts\nconst syncSources = loader.loadSync('.', options)\n```\n\nEach returned source contains the parsed `document`, the matching `rawSDL`, and the provider file's\n`location`. When registering the class with `@graphql-tools/load`, use one external-fragment pointer\nfor each package being resolved. The loader does not de-duplicate separate invocations for repeated\npointers.\n\n### 3. Direct resolver API\n\nUse the resolver functions when you need the external file list or fragment metadata rather than a\nGraphQL Tools loader result:\n\n```ts\nimport {\n  resolveExternalFragments,\n  resolveExternalFragmentsSync\n} from '@graphql-tools/external-fragment-loader'\n\nconst files = await resolveExternalFragments(options)\nconst syncFiles = resolveExternalFragmentsSync(options)\n```\n\nThe result has this shape:\n\n```text\n[\n  {\n    filePath: '/path/to/packages/shared/src/user-fields.graphql',\n    packageName: '@example/shared',\n    definitions: [{ name: 'UserFields', typeCondition: 'User' }]\n  }\n]\n```\n\nThis API returns file metadata, not parsed ASTs. Passing the returned `filePath` values as Codegen\n`documents`/`externalDocuments` works, but Codegen will read and parse those files again. Use the\ndefault loader or the class-based loader when you want to reuse the parsed documents.\n\n## Caching\n\nPackage fragment maps, parsed sources, and `package.json` dependency metadata are cached between\nresolver calls. Consumer package maps are not normally retained unless the consumer package was\npreviously loaded as a provider.\n\nWhen running the loader in **watch mode** — for example, to run Codegen in the background while\nusing an IDE so that the package's generated GraphQL types are regenerated automatically whenever a\nfile changes — consider setting the following options:\n\n- Set `invalidateTargetPackageCache: true` to invalidate the cached fragment map and `package.json`\n  dependency metadata for the target package specified by `packageDir` before each resolution call.\n  This prevents stale data when a package that was previously cached as a provider is later scanned\n  as the consumer.\n\n- Set `cacheTTL` (for example, to `10000` for 10 seconds) so cached provider data eventually\n  expires. This helps avoid stale data when a provider package is updated indirectly, for example by\n  a `git merge`, while the watch process is still running.\n\n## Using filters\n\nThe filters are optional pre-filters: they run before the expensive dependency scanning and GraphQL\nparsing work. Restricting the package names and files early can be faster than parsing every source\nfile in every dependency package.\n\nIn a benchmark of the large monorepo this loader was written for, the approximate observed time\nreductions were as follows (with total reduction of 68%):\n\n- `fileContentFilter`: 60%\n- `packageNameFilter`: 4%\n- `packageDependencyFilter`: 4%\n\n### Filtering files by content\n\nUse `fileContentFilter` to skip source files that don't contain GraphQL. The file content is read\nonce and passed to the predicate, but files returning `false` are not parsed or plucked for GraphQL\ndocuments:\n\n```ts\nconst options = {\n  packageDir,\n  externalPackagesDirs,\n  fileContentFilter: (content, filePath) => {\n    // Keep standalone GraphQL files and match GraphQL tags or magic comments in code files.\n    return (\n      /\\.(graphql|gql)$/.test(filePath) ||\n      /\\b(?:gql|graphql)\\s*`/.test(content) ||\n      /\\/\\*\\s*graphql\\s*\\*\\//i.test(content)\n    )\n  }\n}\n```\n\nThis is especially useful when packages contain many TypeScript or JavaScript files but only a small\nnumber of them contain GraphQL tags. A file-content filter should be broad enough not to exclude\ncustom GraphQL tag identifiers that are configured through `pluckConfig`.\n\n### Filtering dependency packages by name\n\nUse `packageNameFilter` to limit which `package.json` dependencies are considered as providers. The\nfilter is applied to direct and transitive dependency names before their files are scanned:\n\n```ts\nconst options = {\n  packageDir,\n  externalPackagesDirs,\n  packageNameFilter: packageName =>\n    packageName.startsWith('my-company-name-') || packageName === 'shared-graphql'\n}\n```\n\nPackages rejected by this filter are not searched. If a required fragment is defined in a rejected\npackage, the resolver reports it as unresolved.\n\n### Filtering by package dependencies\n\nUse `packageDependencyFilter` to skip scanning packages that don't use GraphQL, without affecting\ndependency traversal. The filter receives the merged `dependencies` and `devDependencies` record\nfrom each package's `package.json` by default, or only `dependencies` when `includeDevDependencies`\nis `false`. It returns `boolean`. Packages that return `false` are still traversed for their own\ntransitive dependencies — they are just not scanned for fragment definitions:\n\n```ts\nconst options = {\n  packageDir,\n  externalPackagesDirs,\n  packageDependencyFilter: deps => '@apollo/client' in deps\n}\n```\n\nThis is useful in large monorepos where many packages don't contain GraphQL but sit in the\ndependency chain between the consumer and the packages that do. Without this filter, every reachable\npackage gets its source files globbed and read. With the filter, only packages that pass the\npredicate are scanned, while non-GraphQL intermediaries are still traversed so that GraphQL packages\nbehind them are found:\n\n```text\nA (consumer) → B (no GraphQL) → C (has GraphQL)\n```\n","packages/merge/README.md":"Check API Reference for more information about this package;\nhttps://www.graphql-tools.com/docs/api/modules/merge_src\n\nYou can also learn more about Schema Merging in this chapter;\nhttps://www.graphql-tools.com/docs/schema-merging\n","packages/mock/README.md":"Check API Reference for more information about this package;\nhttps://www.graphql-tools.com/docs/api/modules/mock_src\n\nYou can also learn more about Mocking in this chapter; https://www.graphql-tools.com/docs/mocking\n","packages/optimize/README.md":"# GraphQL Tools: `DocumentNode` Optimizer\n\nThis package is intended to allow developers to optimize `DocumentNode` objects created by `graphql`\nlibrary.\n\nIt's built as a set of small optimizers you can compose to get the most out of your GraphQL setup.\n\nThe goal of this package is mostly around making optimizations for the way the data is stored in\n`DocumentNode`, and not to the essence of the `DocumentNode`.\n\n## Getting Started\n\n    npm install -D @graphql-tools/optimize\n\n## API\n\nTo get started with this tool, import it and run it over your `DocumentNode`.\n\n```ts\nimport { optimizeDocumentNode } from '@graphql-tools/optimize';\n\nconst myDocument: DocumentNode = { ... }\nconst optimizedDocument = optimizeDocumentNode(myDocument);\n```\n\n### Customizing Optimizers\n\nBy default, we apply all optimizers available in this repo over your document. It shouldn't effect\nany runtime since we just remove dead or unused areas.\n\nYou can modify the list of optimizers this way:\n\n```ts\nimport { optimizeDocumentNode, removeDescriptions } from '@graphql-tools/optimize';\n\nconst myDocument: DocumentNode = { ... }\nconst optimizedDocument = optimizeDocumentNode(myDocument, [removeDescriptions]);\n```\n\n### Writing your own optimizer\n\nYou can create your own optimizer to manipulate `DocumentNode`, the API signature is pretty simple:\n\n```ts\nexport type DocumentOptimizer = (input: DocumentNode) => DocumentNode\n```\n\nTake a look at [./optimizers](this directory for inspiration and implementation reference).\n","packages/relay-operation-optimizer/README.md":"Check API Reference for more information about this package;\nhttps://www.graphql-tools.com/docs/api/modules/relay_operation_optimizer_src\n\nYou can also learn more about Relay Operation Optimizer in this chapter;\nhttps://www.graphql-tools.com/docs/relay-operation-optimizer\n","packages/resolvers-composition/README.md":"Check API Reference for more information about this package;\nhttps://www.graphql-tools.com/docs/api/modules/resolvers_composition_src\n\nYou can also learn more about Resolvers Composition in this chapter;\nhttps://www.graphql-tools.com/docs/resolvers-composition\n","packages/schema/README.md":"Check API Reference for more information about this package;\nhttps://www.graphql-tools.com/docs/api/modules/schema_src\n\nYou can also learn more about Generating Executable Schemas in this chapter;\nhttps://www.graphql-tools.com/docs/generate-schema\n","packages/webpack-loader-runtime/README.md":"# GraphQL Tools Webpack Loader Runtime helpers\n","packages/webpack-loader/README.md":"# GraphQL Tools Webpack Loader\n\nA webpack loader to preprocess GraphQL Documents (operations, fragments and SDL)\n\nSlightly different fork of\n[graphql-tag/loader](https://github.com/apollographql/graphql-tag/pull/304).\n\n    npm install @graphql-tools/webpack-loader\n\nHow is it different from `graphql-tag`? It removes locations entirely, doesn't include sources\n(string content of imported files), no warnings about duplicated fragment names and supports more\ncustom scenarios.\n\n## Options\n\n- `noDescription` (_default: `false`_) - strips descriptions from SDL documents. Has no effect on\n  operations or fragments.\n- `noEmptyNodes` (_default: `false`_) - strips empty `arguments`, `directives`, and\n  `variableDefinitions` from SDL documents. Has no effect on operations or fragments.\n- `noLoc` - accepted for compatibility. Location information is always stripped.\n- `replaceKinds` (_default: `false`_) - replaces `\"kind\": \"Document\"` strings in the emitted AST\n  with `Kind.DOCUMENT` references from `graphql/language/kinds`.\n- `esModule` (_default: `false`_) - emit `export default` instead of `module.exports`. `#import`\n  then reads the default export of the imported document.\n- `importHelpers` (_default: `false`_) - `require` `useUnique` from\n  `@graphql-tools/webpack-loader-runtime` instead of inlining the helper.\n\n## Importing GraphQL files\n\n_To add support for importing `.graphql`/`.gql` files, see\n[Webpack loading and preprocessing](#webpack-loading-and-preprocessing) below._\n\nGiven a file `MyQuery.graphql`\n\n```graphql\nquery MyQuery {\n  ...\n}\n```\n\nIf you have configured\n[the webpack @graphql-tools/webpack-loader](#webpack-loading-and-preprocessing), you can import\nmodules containing graphQL queries. The imported value will be the pre-built AST.\n\n```ts\nimport MyQuery from './query.graphql'\n```\n\n### Preprocessing queries and fragments\n\nPreprocessing GraphQL queries and fragments into ASTs at build time can greatly improve load times.\n\n#### Webpack loading and preprocessing\n\nUsing the included `@graphql-tools/webpack-loader` it is possible to maintain query logic that is\nseparate from the rest of your application logic. With the loader configured, imported graphQL files\nwill be converted to AST during the webpack build process.\n\n```js\n{\n  loaders: [\n    {\n      test: /\\.(graphql|gql)$/,\n      exclude: /node_modules/,\n      loader: '@graphql-tools/webpack-loader',\n      options: {\n        /* ... */\n      }\n    }\n  ],\n}\n```\n"},"files":{"packages/documents/README.md":"# `@graphql-tools/documents`\n\nUtilities for GraphQL documents.\n\n## Install\n\n```bash\nnpm install @graphql-tools/documents\n```\n\n## Contents\n\n### Print GraphQL Documents\n\nA stable way to print a GraphQL document. All executable/fragment variable definitions, fields are\nprinted in a stable way. Useful for stuff like persisted GraphQL operations.\n\n#### Usage\n\n```ts\nimport { parse } from 'graphql'\nimport { printExecutableGraphQLDocument } from '@graphql-tools/documents'\n\nconst inputDocument = parse(/* GraphQL */ `\n  query A {\n    ... on Query {\n      a {\n        ...B\n        b\n      }\n    }\n    ... on Query {\n      a {\n        ...B\n        a\n      }\n    }\n  }\n\n  fragment B on Query {\n    c\n  }\n`)\nconst outputStr = printExecutableGraphQLDocument(inputDocument)\nconsole.assert(\n  outputStr ===\n    'fragment B on Query { c } query A { ... on Query { a { a ...B } } ... on Query { a { b ...B } } }',\n  'Stuff is not equal.'\n)\n```\n\n#### Rules\n\n- Fragments are always printed before executable operations\n- Executable operations are sorted alphabetically by name.\n- Arguments (Directive, Fields) are sorted alphabetical\n- Selections sets are sorted Field, FragmentSpread, InlineFragmentSpread (sorted based on\n  TypeCondition, inner SelectionSet)\n","packages/executor/README.md":"## `@graphql-tools/executor`\n\nFork of GraphQL.js' execute function\n","packages/graphql-tag-pluck/README.md":"Check API Reference for more information about this package;\nhttps://www.graphql-tools.com/docs/api/modules/graphql_tag_pluck_src\n\nYou can also learn more about GraphQL Tag Pluck in this chapter;\nhttps://www.graphql-tools.com/docs/graphql-tag-pluck\n","packages/import/README.md":"Check API Reference for more information about this package;\nhttps://www.graphql-tools.com/docs/api/modules/import_src\n\nYou can also learn more about GraphQL Import in this chapter;\nhttps://www.graphql-tools.com/docs/schema-loading#using-import-expression\n","packages/jest-transform/README.md":"# GraphQL Jest Transform\n\nA Jest transformer to preprocess GraphQL Documents (operations, fragments and SDL)\n\n    npm install @graphql-tools/jest-transform\n\nIn your `package.json`:\n\n```json\n{\n  \"jest\": {\n    \"transform\": {\n      \"\\\\.(gql|graphql)$\": \"@graphql-tools/jest-transform\"\n    }\n  }\n}\n```\n\nor `jest.config.js`:\n\n```js\nmodule.exports = {\n  // ...\n  transform: {\n    '\\\\.(gql|graphql)$': '@graphql-tools/jest-transform'\n  }\n}\n```\n\n> How is it different from `jest-transform-graphql`? It doesn't use `graphql-tag/loader` under the\n> hood but our own, more optimized and customisable `@graphql-tools/webpack-loader`.\n\n## Options\n\n- noDescription (_default: false_) - removes descriptions\n- esModule (_default: false_) - uses import and export statements instead of CommonJS\n\n```json\n{\n  \"globals\": {\n    \"graphql\": {\n      \"noDescription\": true\n    }\n  }\n}\n```\n","packages/links/README.md":"Check API Reference for more information about this package;\nhttps://www.graphql-tools.com/docs/api/modules/links_src\n\nYou can also learn more about Apollo Links in Schema Wrapping in this chapter;\nhttps://www.graphql-tools.com/docs/remote-schemas#wrapschemaschemaconfig\n","packages/load-files/README.md":"Check API Reference for more information about this package;\nhttps://www.graphql-tools.com/docs/api/modules/load_files_src\n\nYou can also learn more about File Loading in this chapter;\nhttps://www.graphql-tools.com/docs/schema-merging#file-loading\n","packages/load/README.md":"Check API Reference for more information about this package;\nhttps://www.graphql-tools.com/docs/api/modules/load_src\n\nYou can also learn more about Apollo Links in Schema Loading in this chapter;\nhttps://www.graphql-tools.com/docs/schema-loading\n\nYou can also learn more about Apollo Links in Documents Loading in this chapter;\nhttps://www.graphql-tools.com/docs/documents-loading\n","packages/loaders/external-fragment/README.md":"# @graphql-tools/external-fragment-loader\n\nResolves missing GraphQL fragments by following direct and transitive dependencies in\n`package.json`, loading only the external fragments the package needs.\n\n## Installation\n\n```sh\nnpm install @graphql-tools/external-fragment-loader\n```\n\nThe resolver requires a target (consumer) package directory and one or more directories containing\nits dependency packages:\n\n```ts\nconst options = {\n  packageDir: '/path/to/packages/my-app',\n  externalPackagesDirs: ['/path/to/packages']\n}\n```\n\n`packageDir` and `externalPackagesDirs` should be absolute paths. By default, the loader scans `src`\ndirectory in the above packages for `.ts`, `.tsx`, `.js`, `.jsx`, `.graphql`, and `.gql` files.\nThese defaults can be changed with the options described in [`options.ts`](./src/options.ts).\n\n## Three API entry points\n\n| Entry point                | Returns                                                        | Use it when                                                                                    |\n| -------------------------- | -------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |\n| Default export             | `DocumentNode` (or `Promise<DocumentNode>` with `async: true`) | Configuring a Codegen or GraphQL Tools custom loader; uses the synchronous resolver by default |\n| `ExternalFragmentLoader`   | `Source[]` with `document`, `rawSDL`, and `location`           | Using `@graphql-tools/load` programmatically (can be async)                                    |\n| `resolveExternalFragments` | File metadata, including `filePath` and fragment definitions   | Building a file list or another custom workflow                                                |\n\nEach entry point has a synchronous variant where applicable. The async and sync variants are:\n\n- `async: true` / `async: false`\n- `ExternalFragmentLoader.load()` / `ExternalFragmentLoader.loadSync()`\n- `resolveExternalFragments()` / `resolveExternalFragmentsSync()`\n\n### 1. Default loader export (for GraphQL Code Generator)\n\nThe default export returns a single merged `DocumentNode`. This is the simplest option for GraphQL\nCode Generator because Codegen's custom-loader path expects one `DocumentNode` or one `Source`.\n\nThis is a sample of code generation for `packages/my-package`. The script runs from the monorepo\nroot.\n\n```ts\nimport { resolve } from 'node:path'\nimport type { CodegenConfig } from '@graphql-codegen/cli'\n\nconst packageDir = resolve('packages/my-package')\nconst externalPackagesDir = resolve('packages')\n\nconst config: CodegenConfig = {\n  schema: './schema.graphql',\n  documents: ['./packages/my-package/src/**/*.graphql'],\n  externalDocuments: [\n    {\n      // a pointer that triggers the custom loader for the consumer package\n      [packageDir]: {\n        loader: '@graphql-tools/external-fragment-loader',\n        packageDir,\n        externalPackagesDirs: [externalPackagesDir],\n        async: true // codegen can consume Promise<DocumentNode> directly\n      }\n    }\n  ],\n  generates: {\n    './packages/my-package/src/__generated__/types.ts': {\n      plugins: ['typescript', 'typescript-operations']\n    }\n  }\n}\n\nexport default config\n```\n\nUse at most one external-fragment pointer for each `packageDir` in a Codegen configuration. The\nloader returns all required external fragments for that package; repeating the pointer causes those\nfragments to be loaded more than once and can produce duplicate fragment definitions. Normal\ndocument pointers can still be listed alongside the single external-fragment pointer.\n\nThe default export uses the synchronous resolver unless `async: true` is set. With `async: true`, it\nreturns a `Promise<DocumentNode>` and uses the asynchronous resolver. Use this option with Codegen\nor another asynchronous loading API; omit it or set it to `false` when using `loadDocumentsSync`.\n\n### 2. Class-based loader\n\nUse `ExternalFragmentLoader` when calling `@graphql-tools/load` directly or when you need the\nindividual `Source` objects:\n\n```ts\nimport { ExternalFragmentLoader } from '@graphql-tools/external-fragment-loader'\n\nconst loader = new ExternalFragmentLoader()\n\nconst sources = await loader.load('.', {\n  packageDir,\n  externalPackagesDirs: [externalPackagesDir]\n})\n```\n\nTo register the class with `@graphql-tools/load`, pass it in the `loaders` option for the pointer\nthat represents the external-fragment document:\n\n```ts\nimport { loadDocuments } from '@graphql-tools/load'\n\nconst sources = await loadDocuments(['./external-fragments.graphql'], {\n  loaders: [loader],\n  packageDir,\n  externalPackagesDirs: [externalPackagesDir]\n})\n```\n\nThe loader also exposes a **synchronous** method:\n\n```ts\nconst syncSources = loader.loadSync('.', options)\n```\n\nEach returned source contains the parsed `document`, the matching `rawSDL`, and the provider file's\n`location`. When registering the class with `@graphql-tools/load`, use one external-fragment pointer\nfor each package being resolved. The loader does not de-duplicate separate invocations for repeated\npointers.\n\n### 3. Direct resolver API\n\nUse the resolver functions when you need the external file list or fragment metadata rather than a\nGraphQL Tools loader result:\n\n```ts\nimport {\n  resolveExternalFragments,\n  resolveExternalFragmentsSync\n} from '@graphql-tools/external-fragment-loader'\n\nconst files = await resolveExternalFragments(options)\nconst syncFiles = resolveExternalFragmentsSync(options)\n```\n\nThe result has this shape:\n\n```text\n[\n  {\n    filePath: '/path/to/packages/shared/src/user-fields.graphql',\n    packageName: '@example/shared',\n    definitions: [{ name: 'UserFields', typeCondition: 'User' }]\n  }\n]\n```\n\nThis API returns file metadata, not parsed ASTs. Passing the returned `filePath` values as Codegen\n`documents`/`externalDocuments` works, but Codegen will read and parse those files again. Use the\ndefault loader or the class-based loader when you want to reuse the parsed documents.\n\n## Caching\n\nPackage fragment maps, parsed sources, and `package.json` dependency metadata are cached between\nresolver calls. Consumer package maps are not normally retained unless the consumer package was\npreviously loaded as a provider.\n\nWhen running the loader in **watch mode** — for example, to run Codegen in the background while\nusing an IDE so that the package's generated GraphQL types are regenerated automatically whenever a\nfile changes — consider setting the following options:\n\n- Set `invalidateTargetPackageCache: true` to invalidate the cached fragment map and `package.json`\n  dependency metadata for the target package specified by `packageDir` before each resolution call.\n  This prevents stale data when a package that was previously cached as a provider is later scanned\n  as the consumer.\n\n- Set `cacheTTL` (for example, to `10000` for 10 seconds) so cached provider data eventually\n  expires. This helps avoid stale data when a provider package is updated indirectly, for example by\n  a `git merge`, while the watch process is still running.\n\n## Using filters\n\nThe filters are optional pre-filters: they run before the expensive dependency scanning and GraphQL\nparsing work. Restricting the package names and files early can be faster than parsing every source\nfile in every dependency package.\n\nIn a benchmark of the large monorepo this loader was written for, the approximate observed time\nreductions were as follows (with total reduction of 68%):\n\n- `fileContentFilter`: 60%\n- `packageNameFilter`: 4%\n- `packageDependencyFilter`: 4%\n\n### Filtering files by content\n\nUse `fileContentFilter` to skip source files that don't contain GraphQL. The file content is read\nonce and passed to the predicate, but files returning `false` are not parsed or plucked for GraphQL\ndocuments:\n\n```ts\nconst options = {\n  packageDir,\n  externalPackagesDirs,\n  fileContentFilter: (content, filePath) => {\n    // Keep standalone GraphQL files and match GraphQL tags or magic comments in code files.\n    return (\n      /\\.(graphql|gql)$/.test(filePath) ||\n      /\\b(?:gql|graphql)\\s*`/.test(content) ||\n      /\\/\\*\\s*graphql\\s*\\*\\//i.test(content)\n    )\n  }\n}\n```\n\nThis is especially useful when packages contain many TypeScript or JavaScript files but only a small\nnumber of them contain GraphQL tags. A file-content filter should be broad enough not to exclude\ncustom GraphQL tag identifiers that are configured through `pluckConfig`.\n\n### Filtering dependency packages by name\n\nUse `packageNameFilter` to limit which `package.json` dependencies are considered as providers. The\nfilter is applied to direct and transitive dependency names before their files are scanned:\n\n```ts\nconst options = {\n  packageDir,\n  externalPackagesDirs,\n  packageNameFilter: packageName =>\n    packageName.startsWith('my-company-name-') || packageName === 'shared-graphql'\n}\n```\n\nPackages rejected by this filter are not searched. If a required fragment is defined in a rejected\npackage, the resolver reports it as unresolved.\n\n### Filtering by package dependencies\n\nUse `packageDependencyFilter` to skip scanning packages that don't use GraphQL, without affecting\ndependency traversal. The filter receives the merged `dependencies` and `devDependencies` record\nfrom each package's `package.json` by default, or only `dependencies` when `includeDevDependencies`\nis `false`. It returns `boolean`. Packages that return `false` are still traversed for their own\ntransitive dependencies — they are just not scanned for fragment definitions:\n\n```ts\nconst options = {\n  packageDir,\n  externalPackagesDirs,\n  packageDependencyFilter: deps => '@apollo/client' in deps\n}\n```\n\nThis is useful in large monorepos where many packages don't contain GraphQL but sit in the\ndependency chain between the consumer and the packages that do. Without this filter, every reachable\npackage gets its source files globbed and read. With the filter, only packages that pass the\npredicate are scanned, while non-GraphQL intermediaries are still traversed so that GraphQL packages\nbehind them are found:\n\n```text\nA (consumer) → B (no GraphQL) → C (has GraphQL)\n```\n","packages/merge/README.md":"Check API Reference for more information about this package;\nhttps://www.graphql-tools.com/docs/api/modules/merge_src\n\nYou can also learn more about Schema Merging in this chapter;\nhttps://www.graphql-tools.com/docs/schema-merging\n","packages/mock/README.md":"Check API Reference for more information about this package;\nhttps://www.graphql-tools.com/docs/api/modules/mock_src\n\nYou can also learn more about Mocking in this chapter; https://www.graphql-tools.com/docs/mocking\n","packages/optimize/README.md":"# GraphQL Tools: `DocumentNode` Optimizer\n\nThis package is intended to allow developers to optimize `DocumentNode` objects created by `graphql`\nlibrary.\n\nIt's built as a set of small optimizers you can compose to get the most out of your GraphQL setup.\n\nThe goal of this package is mostly around making optimizations for the way the data is stored in\n`DocumentNode`, and not to the essence of the `DocumentNode`.\n\n## Getting Started\n\n    npm install -D @graphql-tools/optimize\n\n## API\n\nTo get started with this tool, import it and run it over your `DocumentNode`.\n\n```ts\nimport { optimizeDocumentNode } from '@graphql-tools/optimize';\n\nconst myDocument: DocumentNode = { ... }\nconst optimizedDocument = optimizeDocumentNode(myDocument);\n```\n\n### Customizing Optimizers\n\nBy default, we apply all optimizers available in this repo over your document. It shouldn't effect\nany runtime since we just remove dead or unused areas.\n\nYou can modify the list of optimizers this way:\n\n```ts\nimport { optimizeDocumentNode, removeDescriptions } from '@graphql-tools/optimize';\n\nconst myDocument: DocumentNode = { ... }\nconst optimizedDocument = optimizeDocumentNode(myDocument, [removeDescriptions]);\n```\n\n### Writing your own optimizer\n\nYou can create your own optimizer to manipulate `DocumentNode`, the API signature is pretty simple:\n\n```ts\nexport type DocumentOptimizer = (input: DocumentNode) => DocumentNode\n```\n\nTake a look at [./optimizers](this directory for inspiration and implementation reference).\n","packages/relay-operation-optimizer/README.md":"Check API Reference for more information about this package;\nhttps://www.graphql-tools.com/docs/api/modules/relay_operation_optimizer_src\n\nYou can also learn more about Relay Operation Optimizer in this chapter;\nhttps://www.graphql-tools.com/docs/relay-operation-optimizer\n","packages/resolvers-composition/README.md":"Check API Reference for more information about this package;\nhttps://www.graphql-tools.com/docs/api/modules/resolvers_composition_src\n\nYou can also learn more about Resolvers Composition in this chapter;\nhttps://www.graphql-tools.com/docs/resolvers-composition\n","packages/schema/README.md":"Check API Reference for more information about this package;\nhttps://www.graphql-tools.com/docs/api/modules/schema_src\n\nYou can also learn more about Generating Executable Schemas in this chapter;\nhttps://www.graphql-tools.com/docs/generate-schema\n","packages/webpack-loader-runtime/README.md":"# GraphQL Tools Webpack Loader Runtime helpers\n","packages/webpack-loader/README.md":"# GraphQL Tools Webpack Loader\n\nA webpack loader to preprocess GraphQL Documents (operations, fragments and SDL)\n\nSlightly different fork of\n[graphql-tag/loader](https://github.com/apollographql/graphql-tag/pull/304).\n\n    npm install @graphql-tools/webpack-loader\n\nHow is it different from `graphql-tag`? It removes locations entirely, doesn't include sources\n(string content of imported files), no warnings about duplicated fragment names and supports more\ncustom scenarios.\n\n## Options\n\n- `noDescription` (_default: `false`_) - strips descriptions from SDL documents. Has no effect on\n  operations or fragments.\n- `noEmptyNodes` (_default: `false`_) - strips empty `arguments`, `directives`, and\n  `variableDefinitions` from SDL documents. Has no effect on operations or fragments.\n- `noLoc` - accepted for compatibility. Location information is always stripped.\n- `replaceKinds` (_default: `false`_) - replaces `\"kind\": \"Document\"` strings in the emitted AST\n  with `Kind.DOCUMENT` references from `graphql/language/kinds`.\n- `esModule` (_default: `false`_) - emit `export default` instead of `module.exports`. `#import`\n  then reads the default export of the imported document.\n- `importHelpers` (_default: `false`_) - `require` `useUnique` from\n  `@graphql-tools/webpack-loader-runtime` instead of inlining the helper.\n\n## Importing GraphQL files\n\n_To add support for importing `.graphql`/`.gql` files, see\n[Webpack loading and preprocessing](#webpack-loading-and-preprocessing) below._\n\nGiven a file `MyQuery.graphql`\n\n```graphql\nquery MyQuery {\n  ...\n}\n```\n\nIf you have configured\n[the webpack @graphql-tools/webpack-loader](#webpack-loading-and-preprocessing), you can import\nmodules containing graphQL queries. The imported value will be the pre-built AST.\n\n```ts\nimport MyQuery from './query.graphql'\n```\n\n### Preprocessing queries and fragments\n\nPreprocessing GraphQL queries and fragments into ASTs at build time can greatly improve load times.\n\n#### Webpack loading and preprocessing\n\nUsing the included `@graphql-tools/webpack-loader` it is possible to maintain query logic that is\nseparate from the rest of your application logic. With the loader configured, imported graphQL files\nwill be converted to AST during the webpack build process.\n\n```js\n{\n  loaders: [\n    {\n      test: /\\.(graphql|gql)$/,\n      exclude: /node_modules/,\n      loader: '@graphql-tools/webpack-loader',\n      options: {\n        /* ... */\n      }\n    }\n  ],\n}\n```\n"},"items":[{"name":"README.md","path":"packages/documents/README.md","rawUrl":"https://raw.githubusercontent.com/ardatan/graphql-tools/HEAD/packages/documents/README.md","title":"documents Documentation","category":"plugin-manifest","format":"markdown","content":"# `@graphql-tools/documents`\n\nUtilities for GraphQL documents.\n\n## Install\n\n```bash\nnpm install @graphql-tools/documents\n```\n\n## Contents\n\n### Print GraphQL Documents\n\nA stable way to print a GraphQL document. All executable/fragment variable definitions, fields are\nprinted in a stable way. Useful for stuff like persisted GraphQL operations.\n\n#### Usage\n\n```ts\nimport { parse } from 'graphql'\nimport { printExecutableGraphQLDocument } from '@graphql-tools/documents'\n\nconst inputDocument = parse(/* GraphQL */ `\n  query A {\n    ... on Query {\n      a {\n        ...B\n        b\n      }\n    }\n    ... on Query {\n      a {\n        ...B\n        a\n      }\n    }\n  }\n\n  fragment B on Query {\n    c\n  }\n`)\nconst outputStr = printExecutableGraphQLDocument(inputDocument)\nconsole.assert(\n  outputStr ===\n    'fragment B on Query { c } query A { ... on Query { a { a ...B } } ... on Query { a { b ...B } } }',\n  'Stuff is not equal.'\n)\n```\n\n#### Rules\n\n- Fragments are always printed before executable operations\n- Executable operations are sorted alphabetically by name.\n- Arguments (Directive, Fields) are sorted alphabetical\n- Selections sets are sorted Field, FragmentSpread, InlineFragmentSpread (sorted based on\n  TypeCondition, inner SelectionSet)\n","isInternal":false,"tokens":287,"sizeBytes":1246},{"name":"README.md","path":"packages/executor/README.md","rawUrl":"https://raw.githubusercontent.com/ardatan/graphql-tools/HEAD/packages/executor/README.md","title":"executor Documentation","category":"plugin-manifest","format":"markdown","content":"## `@graphql-tools/executor`\n\nFork of GraphQL.js' execute function\n","isInternal":false,"tokens":17,"sizeBytes":67},{"name":"README.md","path":"packages/graphql-tag-pluck/README.md","rawUrl":"https://raw.githubusercontent.com/ardatan/graphql-tools/HEAD/packages/graphql-tag-pluck/README.md","title":"graphql-tag-pluck Documentation","category":"plugin-manifest","format":"markdown","content":"Check API Reference for more information about this package;\nhttps://www.graphql-tools.com/docs/api/modules/graphql_tag_pluck_src\n\nYou can also learn more about GraphQL Tag Pluck in this chapter;\nhttps://www.graphql-tools.com/docs/graphql-tag-pluck\n","isInternal":false,"tokens":53,"sizeBytes":249},{"name":"README.md","path":"packages/import/README.md","rawUrl":"https://raw.githubusercontent.com/ardatan/graphql-tools/HEAD/packages/import/README.md","title":"import Documentation","category":"plugin-manifest","format":"markdown","content":"Check API Reference for more information about this package;\nhttps://www.graphql-tools.com/docs/api/modules/import_src\n\nYou can also learn more about GraphQL Import in this chapter;\nhttps://www.graphql-tools.com/docs/schema-loading#using-import-expression\n","isInternal":false,"tokens":50,"sizeBytes":256},{"name":"README.md","path":"packages/jest-transform/README.md","rawUrl":"https://raw.githubusercontent.com/ardatan/graphql-tools/HEAD/packages/jest-transform/README.md","title":"jest-transform Documentation","category":"plugin-manifest","format":"markdown","content":"# GraphQL Jest Transform\n\nA Jest transformer to preprocess GraphQL Documents (operations, fragments and SDL)\n\n    npm install @graphql-tools/jest-transform\n\nIn your `package.json`:\n\n```json\n{\n  \"jest\": {\n    \"transform\": {\n      \"\\\\.(gql|graphql)$\": \"@graphql-tools/jest-transform\"\n    }\n  }\n}\n```\n\nor `jest.config.js`:\n\n```js\nmodule.exports = {\n  // ...\n  transform: {\n    '\\\\.(gql|graphql)$': '@graphql-tools/jest-transform'\n  }\n}\n```\n\n> How is it different from `jest-transform-graphql`? It doesn't use `graphql-tag/loader` under the\n> hood but our own, more optimized and customisable `@graphql-tools/webpack-loader`.\n\n## Options\n\n- noDescription (_default: false_) - removes descriptions\n- esModule (_default: false_) - uses import and export statements instead of CommonJS\n\n```json\n{\n  \"globals\": {\n    \"graphql\": {\n      \"noDescription\": true\n    }\n  }\n}\n```\n","isInternal":false,"tokens":221,"sizeBytes":866},{"name":"README.md","path":"packages/links/README.md","rawUrl":"https://raw.githubusercontent.com/ardatan/graphql-tools/HEAD/packages/links/README.md","title":"links Documentation","category":"plugin-manifest","format":"markdown","content":"Check API Reference for more information about this package;\nhttps://www.graphql-tools.com/docs/api/modules/links_src\n\nYou can also learn more about Apollo Links in Schema Wrapping in this chapter;\nhttps://www.graphql-tools.com/docs/remote-schemas#wrapschemaschemaconfig\n","isInternal":false,"tokens":59,"sizeBytes":271},{"name":"README.md","path":"packages/load-files/README.md","rawUrl":"https://raw.githubusercontent.com/ardatan/graphql-tools/HEAD/packages/load-files/README.md","title":"load-files Documentation","category":"plugin-manifest","format":"markdown","content":"Check API Reference for more information about this package;\nhttps://www.graphql-tools.com/docs/api/modules/load_files_src\n\nYou can also learn more about File Loading in this chapter;\nhttps://www.graphql-tools.com/docs/schema-merging#file-loading\n","isInternal":false,"tokens":52,"sizeBytes":247},{"name":"README.md","path":"packages/load/README.md","rawUrl":"https://raw.githubusercontent.com/ardatan/graphql-tools/HEAD/packages/load/README.md","title":"load Documentation","category":"plugin-manifest","format":"markdown","content":"Check API Reference for more information about this package;\nhttps://www.graphql-tools.com/docs/api/modules/load_src\n\nYou can also learn more about Apollo Links in Schema Loading in this chapter;\nhttps://www.graphql-tools.com/docs/schema-loading\n\nYou can also learn more about Apollo Links in Documents Loading in this chapter;\nhttps://www.graphql-tools.com/docs/documents-loading\n","isInternal":false,"tokens":75,"sizeBytes":381},{"name":"README.md","path":"packages/loaders/external-fragment/README.md","rawUrl":"https://raw.githubusercontent.com/ardatan/graphql-tools/HEAD/packages/loaders/external-fragment/README.md","title":"external-fragment Documentation","category":"plugin-manifest","format":"markdown","content":"# @graphql-tools/external-fragment-loader\n\nResolves missing GraphQL fragments by following direct and transitive dependencies in\n`package.json`, loading only the external fragments the package needs.\n\n## Installation\n\n```sh\nnpm install @graphql-tools/external-fragment-loader\n```\n\nThe resolver requires a target (consumer) package directory and one or more directories containing\nits dependency packages:\n\n```ts\nconst options = {\n  packageDir: '/path/to/packages/my-app',\n  externalPackagesDirs: ['/path/to/packages']\n}\n```\n\n`packageDir` and `externalPackagesDirs` should be absolute paths. By default, the loader scans `src`\ndirectory in the above packages for `.ts`, `.tsx`, `.js`, `.jsx`, `.graphql`, and `.gql` files.\nThese defaults can be changed with the options described in [`options.ts`](./src/options.ts).\n\n## Three API entry points\n\n| Entry point                | Returns                                                        | Use it when                                                                                    |\n| -------------------------- | -------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |\n| Default export             | `DocumentNode` (or `Promise<DocumentNode>` with `async: true`) | Configuring a Codegen or GraphQL Tools custom loader; uses the synchronous resolver by default |\n| `ExternalFragmentLoader`   | `Source[]` with `document`, `rawSDL`, and `location`           | Using `@graphql-tools/load` programmatically (can be async)                                    |\n| `resolveExternalFragments` | File metadata, including `filePath` and fragment definitions   | Building a file list or another custom workflow                                                |\n\nEach entry point has a synchronous variant where applicable. The async and sync variants are:\n\n- `async: true` / `async: false`\n- `ExternalFragmentLoader.load()` / `ExternalFragmentLoader.loadSync()`\n- `resolveExternalFragments()` / `resolveExternalFragmentsSync()`\n\n### 1. Default loader export (for GraphQL Code Generator)\n\nThe default export returns a single merged `DocumentNode`. This is the simplest option for GraphQL\nCode Generator because Codegen's custom-loader path expects one `DocumentNode` or one `Source`.\n\nThis is a sample of code generation for `packages/my-package`. The script runs from the monorepo\nroot.\n\n```ts\nimport { resolve } from 'node:path'\nimport type { CodegenConfig } from '@graphql-codegen/cli'\n\nconst packageDir = resolve('packages/my-package')\nconst externalPackagesDir = resolve('packages')\n\nconst config: CodegenConfig = {\n  schema: './schema.graphql',\n  documents: ['./packages/my-package/src/**/*.graphql'],\n  externalDocuments: [\n    {\n      // a pointer that triggers the custom loader for the consumer package\n      [packageDir]: {\n        loader: '@graphql-tools/external-fragment-loader',\n        packageDir,\n        externalPackagesDirs: [externalPackagesDir],\n        async: true // codegen can consume Promise<DocumentNode> directly\n      }\n    }\n  ],\n  generates: {\n    './packages/my-package/src/__generated__/types.ts': {\n      plugins: ['typescript', 'typescript-operations']\n    }\n  }\n}\n\nexport default config\n```\n\nUse at most one external-fragment pointer for each `packageDir` in a Codegen configuration. The\nloader returns all required external fragments for that package; repeating the pointer causes those\nfragments to be loaded more than once and can produce duplicate fragment definitions. Normal\ndocument pointers can still be listed alongside the single external-fragment pointer.\n\nThe default export uses the synchronous resolver unless `async: true` is set. With `async: true`, it\nreturns a `Promise<DocumentNode>` and uses the asynchronous resolver. Use this option with Codegen\nor another asynchronous loading API; omit it or set it to `false` when using `loadDocumentsSync`.\n\n### 2. Class-based loader\n\nUse `ExternalFragmentLoader` when calling `@graphql-tools/load` directly or when you need the\nindividual `Source` objects:\n\n```ts\nimport { ExternalFragmentLoader } from '@graphql-tools/external-fragment-loader'\n\nconst loader = new ExternalFragmentLoader()\n\nconst sources = await loader.load('.', {\n  packageDir,\n  externalPackagesDirs: [externalPackagesDir]\n})\n```\n\nTo register the class with `@graphql-tools/load`, pass it in the `loaders` option for the pointer\nthat represents the external-fragment document:\n\n```ts\nimport { loadDocuments } from '@graphql-tools/load'\n\nconst sources = await loadDocuments(['./external-fragments.graphql'], {\n  loaders: [loader],\n  packageDir,\n  externalPackagesDirs: [externalPackagesDir]\n})\n```\n\nThe loader also exposes a **synchronous** method:\n\n```ts\nconst syncSources = loader.loadSync('.', options)\n```\n\nEach returned source contains the parsed `document`, the matching `rawSDL`, and the provider file's\n`location`. When registering the class with `@graphql-tools/load`, use one external-fragment pointer\nfor each package being resolved. The loader does not de-duplicate separate invocations for repeated\npointers.\n\n### 3. Direct resolver API\n\nUse the resolver functions when you need the external file list or fragment metadata rather than a\nGraphQL Tools loader result:\n\n```ts\nimport {\n  resolveExternalFragments,\n  resolveExternalFragmentsSync\n} from '@graphql-tools/external-fragment-loader'\n\nconst files = await resolveExternalFragments(options)\nconst syncFiles = resolveExternalFragmentsSync(options)\n```\n\nThe result has this shape:\n\n```text\n[\n  {\n    filePath: '/path/to/packages/shared/src/user-fields.graphql',\n    packageName: '@example/shared',\n    definitions: [{ name: 'UserFields', typeCondition: 'User' }]\n  }\n]\n```\n\nThis API returns file metadata, not parsed ASTs. Passing the returned `filePath` values as Codegen\n`documents`/`externalDocuments` works, but Codegen will read and parse those files again. Use the\ndefault loader or the class-based loader when you want to reuse the parsed documents.\n\n## Caching\n\nPackage fragment maps, parsed sources, and `package.json` dependency metadata are cached between\nresolver calls. Consumer package maps are not normally retained unless the consumer package was\npreviously loaded as a provider.\n\nWhen running the loader in **watch mode** — for example, to run Codegen in the background while\nusing an IDE so that the package's generated GraphQL types are regenerated automatically whenever a\nfile changes — consider setting the following options:\n\n- Set `invalidateTargetPackageCache: true` to invalidate the cached fragment map and `package.json`\n  dependency metadata for the target package specified by `packageDir` before each resolution call.\n  This prevents stale data when a package that was previously cached as a provider is later scanned\n  as the consumer.\n\n- Set `cacheTTL` (for example, to `10000` for 10 seconds) so cached provider data eventually\n  expires. This helps avoid stale data when a provider package is updated indirectly, for example by\n  a `git merge`, while the watch process is still running.\n\n## Using filters\n\nThe filters are optional pre-filters: they run before the expensive dependency scanning and GraphQL\nparsing work. Restricting the package names and files early can be faster than parsing every source\nfile in every dependency package.\n\nIn a benchmark of the large monorepo this loader was written for, the approximate observed time\nreductions were as follows (with total reduction of 68%):\n\n- `fileContentFilter`: 60%\n- `packageNameFilter`: 4%\n- `packageDependencyFilter`: 4%\n\n### Filtering files by content\n\nUse `fileContentFilter` to skip source files that don't contain GraphQL. The file content is read\nonce and passed to the predicate, but files returning `false` are not parsed or plucked for GraphQL\ndocuments:\n\n```ts\nconst options = {\n  packageDir,\n  externalPackagesDirs,\n  fileContentFilter: (content, filePath) => {\n    // Keep standalone GraphQL files and match GraphQL tags or magic comments in code files.\n    return (\n      /\\.(graphql|gql)$/.test(filePath) ||\n      /\\b(?:gql|graphql)\\s*`/.test(content) ||\n      /\\/\\*\\s*graphql\\s*\\*\\//i.test(content)\n    )\n  }\n}\n```\n\nThis is especially useful when packages contain many TypeScript or JavaScript files but only a small\nnumber of them contain GraphQL tags. A file-content filter should be broad enough not to exclude\ncustom GraphQL tag identifiers that are configured through `pluckConfig`.\n\n### Filtering dependency packages by name\n\nUse `packageNameFilter` to limit which `package.json` dependencies are considered as providers. The\nfilter is applied to direct and transitive dependency names before their files are scanned:\n\n```ts\nconst options = {\n  packageDir,\n  externalPackagesDirs,\n  packageNameFilter: packageName =>\n    packageName.startsWith('my-company-name-') || packageName === 'shared-graphql'\n}\n```\n\nPackages rejected by this filter are not searched. If a required fragment is defined in a rejected\npackage, the resolver reports it as unresolved.\n\n### Filtering by package dependencies\n\nUse `packageDependencyFilter` to skip scanning packages that don't use GraphQL, without affecting\ndependency traversal. The filter receives the merged `dependencies` and `devDependencies` record\nfrom each package's `package.json` by default, or only `dependencies` when `includeDevDependencies`\nis `false`. It returns `boolean`. Packages that return `false` are still traversed for their own\ntransitive dependencies — they are just not scanned for fragment definitions:\n\n```ts\nconst options = {\n  packageDir,\n  externalPackagesDirs,\n  packageDependencyFilter: deps => '@apollo/client' in deps\n}\n```\n\nThis is useful in large monorepos where many packages don't contain GraphQL but sit in the\ndependency chain between the consumer and the packages that do. Without this filter, every reachable\npackage gets its source files globbed and read. With the filter, only packages that pass the\npredicate are scanned, while non-GraphQL intermediaries are still traversed so that GraphQL packages\nbehind them are found:\n\n```text\nA (consumer) → B (no GraphQL) → C (has GraphQL)\n```\n","isInternal":false,"tokens":2118,"sizeBytes":10165},{"name":"README.md","path":"packages/merge/README.md","rawUrl":"https://raw.githubusercontent.com/ardatan/graphql-tools/HEAD/packages/merge/README.md","title":"merge Documentation","category":"plugin-manifest","format":"markdown","content":"Check API Reference for more information about this package;\nhttps://www.graphql-tools.com/docs/api/modules/merge_src\n\nYou can also learn more about Schema Merging in this chapter;\nhttps://www.graphql-tools.com/docs/schema-merging\n","isInternal":false,"tokens":50,"sizeBytes":231},{"name":"README.md","path":"packages/mock/README.md","rawUrl":"https://raw.githubusercontent.com/ardatan/graphql-tools/HEAD/packages/mock/README.md","title":"mock Documentation","category":"plugin-manifest","format":"markdown","content":"Check API Reference for more information about this package;\nhttps://www.graphql-tools.com/docs/api/modules/mock_src\n\nYou can also learn more about Mocking in this chapter; https://www.graphql-tools.com/docs/mocking\n","isInternal":false,"tokens":46,"sizeBytes":216},{"name":"README.md","path":"packages/optimize/README.md","rawUrl":"https://raw.githubusercontent.com/ardatan/graphql-tools/HEAD/packages/optimize/README.md","title":"optimize Documentation","category":"plugin-manifest","format":"markdown","content":"# GraphQL Tools: `DocumentNode` Optimizer\n\nThis package is intended to allow developers to optimize `DocumentNode` objects created by `graphql`\nlibrary.\n\nIt's built as a set of small optimizers you can compose to get the most out of your GraphQL setup.\n\nThe goal of this package is mostly around making optimizations for the way the data is stored in\n`DocumentNode`, and not to the essence of the `DocumentNode`.\n\n## Getting Started\n\n    npm install -D @graphql-tools/optimize\n\n## API\n\nTo get started with this tool, import it and run it over your `DocumentNode`.\n\n```ts\nimport { optimizeDocumentNode } from '@graphql-tools/optimize';\n\nconst myDocument: DocumentNode = { ... }\nconst optimizedDocument = optimizeDocumentNode(myDocument);\n```\n\n### Customizing Optimizers\n\nBy default, we apply all optimizers available in this repo over your document. It shouldn't effect\nany runtime since we just remove dead or unused areas.\n\nYou can modify the list of optimizers this way:\n\n```ts\nimport { optimizeDocumentNode, removeDescriptions } from '@graphql-tools/optimize';\n\nconst myDocument: DocumentNode = { ... }\nconst optimizedDocument = optimizeDocumentNode(myDocument, [removeDescriptions]);\n```\n\n### Writing your own optimizer\n\nYou can create your own optimizer to manipulate `DocumentNode`, the API signature is pretty simple:\n\n```ts\nexport type DocumentOptimizer = (input: DocumentNode) => DocumentNode\n```\n\nTake a look at [./optimizers](this directory for inspiration and implementation reference).\n","isInternal":false,"tokens":319,"sizeBytes":1499},{"name":"README.md","path":"packages/relay-operation-optimizer/README.md","rawUrl":"https://raw.githubusercontent.com/ardatan/graphql-tools/HEAD/packages/relay-operation-optimizer/README.md","title":"relay-operation-optimizer Documentation","category":"plugin-manifest","format":"markdown","content":"Check API Reference for more information about this package;\nhttps://www.graphql-tools.com/docs/api/modules/relay_operation_optimizer_src\n\nYou can also learn more about Relay Operation Optimizer in this chapter;\nhttps://www.graphql-tools.com/docs/relay-operation-optimizer\n","isInternal":false,"tokens":54,"sizeBytes":273},{"name":"README.md","path":"packages/resolvers-composition/README.md","rawUrl":"https://raw.githubusercontent.com/ardatan/graphql-tools/HEAD/packages/resolvers-composition/README.md","title":"resolvers-composition Documentation","category":"plugin-manifest","format":"markdown","content":"Check API Reference for more information about this package;\nhttps://www.graphql-tools.com/docs/api/modules/resolvers_composition_src\n\nYou can also learn more about Resolvers Composition in this chapter;\nhttps://www.graphql-tools.com/docs/resolvers-composition\n","isInternal":false,"tokens":52,"sizeBytes":261},{"name":"README.md","path":"packages/schema/README.md","rawUrl":"https://raw.githubusercontent.com/ardatan/graphql-tools/HEAD/packages/schema/README.md","title":"schema Documentation","category":"plugin-manifest","format":"markdown","content":"Check API Reference for more information about this package;\nhttps://www.graphql-tools.com/docs/api/modules/schema_src\n\nYou can also learn more about Generating Executable Schemas in this chapter;\nhttps://www.graphql-tools.com/docs/generate-schema\n","isInternal":false,"tokens":50,"sizeBytes":248},{"name":"README.md","path":"packages/webpack-loader-runtime/README.md","rawUrl":"https://raw.githubusercontent.com/ardatan/graphql-tools/HEAD/packages/webpack-loader-runtime/README.md","title":"webpack-loader-runtime Documentation","category":"plugin-manifest","format":"markdown","content":"# GraphQL Tools Webpack Loader Runtime helpers\n","isInternal":false,"tokens":9,"sizeBytes":47},{"name":"README.md","path":"packages/webpack-loader/README.md","rawUrl":"https://raw.githubusercontent.com/ardatan/graphql-tools/HEAD/packages/webpack-loader/README.md","title":"webpack-loader Documentation","category":"plugin-manifest","format":"markdown","content":"# GraphQL Tools Webpack Loader\n\nA webpack loader to preprocess GraphQL Documents (operations, fragments and SDL)\n\nSlightly different fork of\n[graphql-tag/loader](https://github.com/apollographql/graphql-tag/pull/304).\n\n    npm install @graphql-tools/webpack-loader\n\nHow is it different from `graphql-tag`? It removes locations entirely, doesn't include sources\n(string content of imported files), no warnings about duplicated fragment names and supports more\ncustom scenarios.\n\n## Options\n\n- `noDescription` (_default: `false`_) - strips descriptions from SDL documents. Has no effect on\n  operations or fragments.\n- `noEmptyNodes` (_default: `false`_) - strips empty `arguments`, `directives`, and\n  `variableDefinitions` from SDL documents. Has no effect on operations or fragments.\n- `noLoc` - accepted for compatibility. Location information is always stripped.\n- `replaceKinds` (_default: `false`_) - replaces `\"kind\": \"Document\"` strings in the emitted AST\n  with `Kind.DOCUMENT` references from `graphql/language/kinds`.\n- `esModule` (_default: `false`_) - emit `export default` instead of `module.exports`. `#import`\n  then reads the default export of the imported document.\n- `importHelpers` (_default: `false`_) - `require` `useUnique` from\n  `@graphql-tools/webpack-loader-runtime` instead of inlining the helper.\n\n## Importing GraphQL files\n\n_To add support for importing `.graphql`/`.gql` files, see\n[Webpack loading and preprocessing](#webpack-loading-and-preprocessing) below._\n\nGiven a file `MyQuery.graphql`\n\n```graphql\nquery MyQuery {\n  ...\n}\n```\n\nIf you have configured\n[the webpack @graphql-tools/webpack-loader](#webpack-loading-and-preprocessing), you can import\nmodules containing graphQL queries. The imported value will be the pre-built AST.\n\n```ts\nimport MyQuery from './query.graphql'\n```\n\n### Preprocessing queries and fragments\n\nPreprocessing GraphQL queries and fragments into ASTs at build time can greatly improve load times.\n\n#### Webpack loading and preprocessing\n\nUsing the included `@graphql-tools/webpack-loader` it is possible to maintain query logic that is\nseparate from the rest of your application logic. With the loader configured, imported graphQL files\nwill be converted to AST during the webpack build process.\n\n```js\n{\n  loaders: [\n    {\n      test: /\\.(graphql|gql)$/,\n      exclude: /node_modules/,\n      loader: '@graphql-tools/webpack-loader',\n      options: {\n        /* ... */\n      }\n    }\n  ],\n}\n```\n","isInternal":false,"tokens":559,"sizeBytes":2455}],"systemPromptSnippet":"<yakaai_skills repo=\"ardatan/graphql-tools\">\n<!-- File: packages/documents/README.md (Tokens: ~287 | Category: plugin-manifest) -->\n# `@graphql-tools/documents`\n\nUtilities for GraphQL documents.\n\n## Install\n\n```bash\nnpm install @graphql-tools/documents\n```\n\n## Contents\n\n### Print GraphQL Documents\n\nA stable way to print a GraphQL document. All executable/fragment variable definitions, fields are\nprinted in a stable way. Useful for stuff like persisted GraphQL operations.\n\n#### Usage\n\n```ts\nimport { parse } from 'graphql'\nimport { printExecutableGraphQLDocument } from '@graphql-tools/documents'\n\nconst inputDocument = parse(/* GraphQL */ `\n  query A {\n    ... on Query {\n      a {\n        ...B\n        b\n      }\n    }\n    ... on Query {\n      a {\n        ...B\n        a\n      }\n    }\n  }\n\n  fragment B on Query {\n    c\n  }\n`)\nconst outputStr = printExecutableGraphQLDocument(inputDocument)\nconsole.assert(\n  outputStr ===\n    'fragment B on Query { c } query A { ... on Query { a { a ...B } } ... on Query { a { b ...B } } }',\n  'Stuff is not equal.'\n)\n```\n\n#### Rules\n\n- Fragments are always printed before executable operations\n- Executable operations are sorted alphabetically by name.\n- Arguments (Directive, Fields) are sorted alphabetical\n- Selections sets are sorted Field, FragmentSpread, InlineFragmentSpread (sorted based on\n  TypeCondition, inner SelectionSet)\n\n<!-- File: packages/executor/README.md (Tokens: ~17 | Category: plugin-manifest) -->\n## `@graphql-tools/executor`\n\nFork of GraphQL.js' execute function\n\n<!-- File: packages/graphql-tag-pluck/README.md (Tokens: ~53 | Category: plugin-manifest) -->\nCheck API Reference for more information about this package;\nhttps://www.graphql-tools.com/docs/api/modules/graphql_tag_pluck_src\n\nYou can also learn more about GraphQL Tag Pluck in this chapter;\nhttps://www.graphql-tools.com/docs/graphql-tag-pluck\n\n<!-- File: packages/import/README.md (Tokens: ~50 | Category: plugin-manifest) -->\nCheck API Reference for more information about this package;\nhttps://www.graphql-tools.com/docs/api/modules/import_src\n\nYou can also learn more about GraphQL Import in this chapter;\nhttps://www.graphql-tools.com/docs/schema-loading#using-import-expression\n\n<!-- File: packages/jest-transform/README.md (Tokens: ~221 | Category: plugin-manifest) -->\n# GraphQL Jest Transform\n\nA Jest transformer to preprocess GraphQL Documents (operations, fragments and SDL)\n\n    npm install @graphql-tools/jest-transform\n\nIn your `package.json`:\n\n```json\n{\n  \"jest\": {\n    \"transform\": {\n      \"\\\\.(gql|graphql)$\": \"@graphql-tools/jest-transform\"\n    }\n  }\n}\n```\n\nor `jest.config.js`:\n\n```js\nmodule.exports = {\n  // ...\n  transform: {\n    '\\\\.(gql|graphql)$': '@graphql-tools/jest-transform'\n  }\n}\n```\n\n> How is it different from `jest-transform-graphql`? It doesn't use `graphql-tag/loader` under the\n> hood but our own, more optimized and customisable `@graphql-tools/webpack-loader`.\n\n## Options\n\n- noDescription (_default: false_) - removes descriptions\n- esModule (_default: false_) - uses import and export statements instead of CommonJS\n\n```json\n{\n  \"globals\": {\n    \"graphql\": {\n      \"noDescription\": true\n    }\n  }\n}\n```\n\n<!-- File: packages/links/README.md (Tokens: ~59 | Category: plugin-manifest) -->\nCheck API Reference for more information about this package;\nhttps://www.graphql-tools.com/docs/api/modules/links_src\n\nYou can also learn more about Apollo Links in Schema Wrapping in this chapter;\nhttps://www.graphql-tools.com/docs/remote-schemas#wrapschemaschemaconfig\n\n<!-- File: packages/load-files/README.md (Tokens: ~52 | Category: plugin-manifest) -->\nCheck API Reference for more information about this package;\nhttps://www.graphql-tools.com/docs/api/modules/load_files_src\n\nYou can also learn more about File Loading in this chapter;\nhttps://www.graphql-tools.com/docs/schema-merging#file-loading\n\n<!-- File: packages/load/README.md (Tokens: ~75 | Category: plugin-manifest) -->\nCheck API Reference for more information about this package;\nhttps://www.graphql-tools.com/docs/api/modules/load_src\n\nYou can also learn more about Apollo Links in Schema Loading in this chapter;\nhttps://www.graphql-tools.com/docs/schema-loading\n\nYou can also learn more about Apollo Links in Documents Loading in this chapter;\nhttps://www.graphql-tools.com/docs/documents-loading\n\n<!-- File: packages/loaders/external-fragment/README.md (Tokens: ~2118 | Category: plugin-manifest) -->\n# @graphql-tools/external-fragment-loader\n\nResolves missing GraphQL fragments by following direct and transitive dependencies in\n`package.json`, loading only the external fragments the package needs.\n\n## Installation\n\n```sh\nnpm install @graphql-tools/external-fragment-loader\n```\n\nThe resolver requires a target (consumer) package directory and one or more directories containing\nits dependency packages:\n\n```ts\nconst options = {\n  packageDir: '/path/to/packages/my-app',\n  externalPackagesDirs: ['/path/to/packages']\n}\n```\n\n`packageDir` and `externalPackagesDirs` should be absolute paths. By default, the loader scans `src`\ndirectory in the above packages for `.ts`, `.tsx`, `.js`, `.jsx`, `.graphql`, and `.gql` files.\nThese defaults can be changed with the options described in [`options.ts`](./src/options.ts).\n\n## Three API entry points\n\n| Entry point                | Returns                                                        | Use it when                                                                                    |\n| -------------------------- | -------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |\n| Default export             | `DocumentNode` (or `Promise<DocumentNode>` with `async: true`) | Configuring a Codegen or GraphQL Tools custom loader; uses the synchronous resolver by default |\n| `ExternalFragmentLoader`   | `Source[]` with `document`, `rawSDL`, and `location`           | Using `@graphql-tools/load` programmatically (can be async)                                    |\n| `resolveExternalFragments` | File metadata, including `filePath` and fragment definitions   | Building a file list or another custom workflow                                                |\n\nEach entry point has a synchronous variant where applicable. The async and sync variants are:\n\n- `async: true` / `async: false`\n- `ExternalFragmentLoader.load()` / `ExternalFragmentLoader.loadSync()`\n- `resolveExternalFragments()` / `resolveExternalFragmentsSync()`\n\n### 1. Default loader export (for GraphQL Code Generator)\n\nThe default export returns a single merged `DocumentNode`. This is the simplest option for GraphQL\nCode Generator because Codegen's custom-loader path expects one `DocumentNode` or one `Source`.\n\nThis is a sample of code generation for `packages/my-package`. The script runs from the monorepo\nroot.\n\n```ts\nimport { resolve } from 'node:path'\nimport type { CodegenConfig } from '@graphql-codegen/cli'\n\nconst packageDir = resolve('packages/my-package')\nconst externalPackagesDir = resolve('packages')\n\nconst config: CodegenConfig = {\n  schema: './schema.graphql',\n  documents: ['./packages/my-package/src/**/*.graphql'],\n  externalDocuments: [\n    {\n      // a pointer that triggers the custom loader for the consumer package\n      [packageDir]: {\n        loader: '@graphql-tools/external-fragment-loader',\n        packageDir,\n        externalPackagesDirs: [externalPackagesDir],\n        async: true // codegen can consume Promise<DocumentNode> directly\n      }\n    }\n  ],\n  generates: {\n    './packages/my-package/src/__generated__/types.ts': {\n      plugins: ['typescript', 'typescript-operations']\n    }\n  }\n}\n\nexport default config\n```\n\nUse at most one external-fragment pointer for each `packageDir` in a Codegen configuration. The\nloader returns all required external fragments for that package; repeating the pointer causes those\nfragments to be loaded more than once and can produce duplicate fragment definitions. Normal\ndocument pointers can still be listed alongside the single external-fragment pointer.\n\nThe default export uses the synchronous resolver unless `async: true` is set. With `async: true`, it\nreturns a `Promise<DocumentNode>` and uses the asynchronous resolver. Use this option with Codegen\nor another asynchronous loading API; omit it or set it to `false` when using `loadDocumentsSync`.\n\n### 2. Class-based loader\n\nUse `ExternalFragmentLoader` when calling `@graphql-tools/load` directly or when you need the\nindividual `Source` objects:\n\n```ts\nimport { ExternalFragmentLoader } from '@graphql-tools/external-fragment-loader'\n\nconst loader = new ExternalFragmentLoader()\n\nconst sources = await loader.load('.', {\n  packageDir,\n  externalPackagesDirs: [externalPackagesDir]\n})\n```\n\nTo register the class with `@graphql-tools/load`, pass it in the `loaders` option for the pointer\nthat represents the external-fragment document:\n\n```ts\nimport { loadDocuments } from '@graphql-tools/load'\n\nconst sources = await loadDocuments(['./external-fragments.graphql'], {\n  loaders: [loader],\n  packageDir,\n  externalPackagesDirs: [externalPackagesDir]\n})\n```\n\nThe loader also exposes a **synchronous** method:\n\n```ts\nconst syncSources = loader.loadSync('.', options)\n```\n\nEach returned source contains the parsed `document`, the matching `rawSDL`, and the provider file's\n`location`. When registering the class with `@graphql-tools/load`, use one external-fragment pointer\nfor each package being resolved. The loader does not de-duplicate separate invocations for repeated\npointers.\n\n### 3. Direct resolver API\n\nUse the resolver functions when you need the external file list or fragment metadata rather than a\nGraphQL Tools loader result:\n\n```ts\nimport {\n  resolveExternalFragments,\n  resolveExternalFragmentsSync\n} from '@graphql-tools/external-fragment-loader'\n\nconst files = await resolveExternalFragments(options)\nconst syncFiles = resolveExternalFragmentsSync(options)\n```\n\nThe result has this shape:\n\n```text\n[\n  {\n    filePath: '/path/to/packages/shared/src/user-fields.graphql',\n    packageName: '@example/shared',\n    definitions: [{ name: 'UserFields', typeCondition: 'User' }]\n  }\n]\n```\n\nThis API returns file metadata, not parsed ASTs. Passing the returned `filePath` values as Codegen\n`documents`/`externalDocuments` works, but Codegen will read and parse those files again. Use the\ndefault loader or the class-based loader when you want to reuse the parsed documents.\n\n## Caching\n\nPackage fragment maps, parsed sources, and `package.json` dependency metadata are cached between\nresolver calls. Consumer package maps are not normally retained unless the consumer package was\npreviously loaded as a provider.\n\nWhen running the loader in **watch mode** — for example, to run Codegen in the background while\nusing an IDE so that the package's generated GraphQL types are regenerated automatically whenever a\nfile changes — consider setting the following options:\n\n- Set `invalidateTargetPackageCache: true` to invalidate the cached fragment map and `package.json`\n  dependency metadata for the target package specified by `packageDir` before each resolution call.\n  This prevents stale data when a package that was previously cached as a provider is later scanned\n  as the consumer.\n\n- Set `cacheTTL` (for example, to `10000` for 10 seconds) so cached provider data eventually\n  expires. This helps avoid stale data when a provider package is updated indirectly, for example by\n  a `git merge`, while the watch process is still running.\n\n## Using filters\n\nThe filters are optional pre-filters: they run before the expensive dependency scanning and GraphQL\nparsing work. Restricting the package names and files early can be faster than parsing every source\nfile in every dependency package.\n\nIn a benchmark of the large monorepo this loader was written for, the approximate observed time\nreductions were as follows (with total reduction of 68%):\n\n- `fileContentFilter`: 60%\n- `packageNameFilter`: 4%\n- `packageDependencyFilter`: 4%\n\n### Filtering files by content\n\nUse `fileContentFilter` to skip source files that don't contain GraphQL. The file content is read\nonce and passed to the predicate, but files returning `false` are not parsed or plucked for GraphQL\ndocuments:\n\n```ts\nconst options = {\n  packageDir,\n  externalPackagesDirs,\n  fileContentFilter: (content, filePath) => {\n    // Keep standalone GraphQL files and match GraphQL tags or magic comments in code files.\n    return (\n      /\\.(graphql|gql)$/.test(filePath) ||\n      /\\b(?:gql|graphql)\\s*`/.test(content) ||\n      /\\/\\*\\s*graphql\\s*\\*\\//i.test(content)\n    )\n  }\n}\n```\n\nThis is especially useful when packages contain many TypeScript or JavaScript files but only a small\nnumber of them contain GraphQL tags. A file-content filter should be broad enough not to exclude\ncustom GraphQL tag identifiers that are configured through `pluckConfig`.\n\n### Filtering dependency packages by name\n\nUse `packageNameFilter` to limit which `package.json` dependencies are considered as providers. The\nfilter is applied to direct and transitive dependency names before their files are scanned:\n\n```ts\nconst options = {\n  packageDir,\n  externalPackagesDirs,\n  packageNameFilter: packageName =>\n    packageName.startsWith('my-company-name-') || packageName === 'shared-graphql'\n}\n```\n\nPackages rejected by this filter are not searched. If a required fragment is defined in a rejected\npackage, the resolver reports it as unresolved.\n\n### Filtering by package dependencies\n\nUse `packageDependencyFilter` to skip scanning packages that don't use GraphQL, without affecting\ndependency traversal. The filter receives the merged `dependencies` and `devDependencies` record\nfrom each package's `package.json` by default, or only `dependencies` when `includeDevDependencies`\nis `false`. It returns `boolean`. Packages that return `false` are still traversed for their own\ntransitive dependencies — they are just not scanned for fragment definitions:\n\n```ts\nconst options = {\n  packageDir,\n  externalPackagesDirs,\n  packageDependencyFilter: deps => '@apollo/client' in deps\n}\n```\n\nThis is useful in large monorepos where many packages don't contain GraphQL but sit in the\ndependency chain between the consumer and the packages that do. Without this filter, every reachable\npackage gets its source files globbed and read. With the filter, only packages that pass the\npredicate are scanned, while non-GraphQL intermediaries are still traversed so that GraphQL packages\nbehind them are found:\n\n```text\nA (consumer) → B (no GraphQL) → C (has GraphQL)\n```\n\n<!-- File: packages/merge/README.md (Tokens: ~50 | Category: plugin-manifest) -->\nCheck API Reference for more information about this package;\nhttps://www.graphql-tools.com/docs/api/modules/merge_src\n\nYou can also learn more about Schema Merging in this chapter;\nhttps://www.graphql-tools.com/docs/schema-merging\n\n<!-- File: packages/mock/README.md (Tokens: ~46 | Category: plugin-manifest) -->\nCheck API Reference for more information about this package;\nhttps://www.graphql-tools.com/docs/api/modules/mock_src\n\nYou can also learn more about Mocking in this chapter; https://www.graphql-tools.com/docs/mocking\n\n<!-- File: packages/optimize/README.md (Tokens: ~319 | Category: plugin-manifest) -->\n# GraphQL Tools: `DocumentNode` Optimizer\n\nThis package is intended to allow developers to optimize `DocumentNode` objects created by `graphql`\nlibrary.\n\nIt's built as a set of small optimizers you can compose to get the most out of your GraphQL setup.\n\nThe goal of this package is mostly around making optimizations for the way the data is stored in\n`DocumentNode`, and not to the essence of the `DocumentNode`.\n\n## Getting Started\n\n    npm install -D @graphql-tools/optimize\n\n## API\n\nTo get started with this tool, import it and run it over your `DocumentNode`.\n\n```ts\nimport { optimizeDocumentNode } from '@graphql-tools/optimize';\n\nconst myDocument: DocumentNode = { ... }\nconst optimizedDocument = optimizeDocumentNode(myDocument);\n```\n\n### Customizing Optimizers\n\nBy default, we apply all optimizers available in this repo over your document. It shouldn't effect\nany runtime since we just remove dead or unused areas.\n\nYou can modify the list of optimizers this way:\n\n```ts\nimport { optimizeDocumentNode, removeDescriptions } from '@graphql-tools/optimize';\n\nconst myDocument: DocumentNode = { ... }\nconst optimizedDocument = optimizeDocumentNode(myDocument, [removeDescriptions]);\n```\n\n### Writing your own optimizer\n\nYou can create your own optimizer to manipulate `DocumentNode`, the API signature is pretty simple:\n\n```ts\nexport type DocumentOptimizer = (input: DocumentNode) => DocumentNode\n```\n\nTake a look at [./optimizers](this directory for inspiration and implementation reference).\n\n<!-- File: packages/relay-operation-optimizer/README.md (Tokens: ~54 | Category: plugin-manifest) -->\nCheck API Reference for more information about this package;\nhttps://www.graphql-tools.com/docs/api/modules/relay_operation_optimizer_src\n\nYou can also learn more about Relay Operation Optimizer in this chapter;\nhttps://www.graphql-tools.com/docs/relay-operation-optimizer\n\n<!-- File: packages/resolvers-composition/README.md (Tokens: ~52 | Category: plugin-manifest) -->\nCheck API Reference for more information about this package;\nhttps://www.graphql-tools.com/docs/api/modules/resolvers_composition_src\n\nYou can also learn more about Resolvers Composition in this chapter;\nhttps://www.graphql-tools.com/docs/resolvers-composition\n\n<!-- File: packages/schema/README.md (Tokens: ~50 | Category: plugin-manifest) -->\nCheck API Reference for more information about this package;\nhttps://www.graphql-tools.com/docs/api/modules/schema_src\n\nYou can also learn more about Generating Executable Schemas in this chapter;\nhttps://www.graphql-tools.com/docs/generate-schema\n\n<!-- File: packages/webpack-loader-runtime/README.md (Tokens: ~9 | Category: plugin-manifest) -->\n# GraphQL Tools Webpack Loader Runtime helpers\n\n<!-- File: packages/webpack-loader/README.md (Tokens: ~559 | Category: plugin-manifest) -->\n# GraphQL Tools Webpack Loader\n\nA webpack loader to preprocess GraphQL Documents (operations, fragments and SDL)\n\nSlightly different fork of\n[graphql-tag/loader](https://github.com/apollographql/graphql-tag/pull/304).\n\n    npm install @graphql-tools/webpack-loader\n\nHow is it different from `graphql-tag`? It removes locations entirely, doesn't include sources\n(string content of imported files), no warnings about duplicated fragment names and supports more\ncustom scenarios.\n\n## Options\n\n- `noDescription` (_default: `false`_) - strips descriptions from SDL documents. Has no effect on\n  operations or fragments.\n- `noEmptyNodes` (_default: `false`_) - strips empty `arguments`, `directives`, and\n  `variableDefinitions` from SDL documents. Has no effect on operations or fragments.\n- `noLoc` - accepted for compatibility. Location information is always stripped.\n- `replaceKinds` (_default: `false`_) - replaces `\"kind\": \"Document\"` strings in the emitted AST\n  with `Kind.DOCUMENT` references from `graphql/language/kinds`.\n- `esModule` (_default: `false`_) - emit `export default` instead of `module.exports`. `#import`\n  then reads the default export of the imported document.\n- `importHelpers` (_default: `false`_) - `require` `useUnique` from\n  `@graphql-tools/webpack-loader-runtime` instead of inlining the helper.\n\n## Importing GraphQL files\n\n_To add support for importing `.graphql`/`.gql` files, see\n[Webpack loading and preprocessing](#webpack-loading-and-preprocessing) below._\n\nGiven a file `MyQuery.graphql`\n\n```graphql\nquery MyQuery {\n  ...\n}\n```\n\nIf you have configured\n[the webpack @graphql-tools/webpack-loader](#webpack-loading-and-preprocessing), you can import\nmodules containing graphQL queries. The imported value will be the pre-built AST.\n\n```ts\nimport MyQuery from './query.graphql'\n```\n\n### Preprocessing queries and fragments\n\nPreprocessing GraphQL queries and fragments into ASTs at build time can greatly improve load times.\n\n#### Webpack loading and preprocessing\n\nUsing the included `@graphql-tools/webpack-loader` it is possible to maintain query logic that is\nseparate from the rest of your application logic. With the loader configured, imported graphQL files\nwill be converted to AST during the webpack build process.\n\n```js\n{\n  loaders: [\n    {\n      test: /\\.(graphql|gql)$/,\n      exclude: /node_modules/,\n      loader: '@graphql-tools/webpack-loader',\n      options: {\n        /* ... */\n      }\n    }\n  ],\n}\n```\n</yakaai_skills>"}