Skip to Content
GraphQL Tools
DocumentationAPILoadersexternal-fragmentsrcinterfacesExternalFragmentLoaderOptions

Interface: ExternalFragmentLoaderOptions

Defined in: packages/loaders/external-fragment/src/options.ts:4 

Extends

Properties

allowLegacySDLEmptyFields?

optional allowLegacySDLEmptyFields?: boolean

Defined in: packages/utils/src/Interfaces.ts:142 

Inherited from

BaseLoaderOptions.allowLegacySDLEmptyFields


allowLegacySDLImplementsInterfaces?

optional allowLegacySDLImplementsInterfaces?: boolean

Defined in: packages/utils/src/Interfaces.ts:143 

Inherited from

BaseLoaderOptions.allowLegacySDLImplementsInterfaces


assumeValid?

optional assumeValid?: boolean

Defined in: node_modules/graphql/type/schema.d.mts:612

Internal

When building a schema from a GraphQL service’s introspection result, it might be safe to assume the schema is valid. Set to true to assume the produced schema is valid.

Default: false

Inherited from

BaseLoaderOptions.assumeValid


assumeValidSDL?

optional assumeValidSDL?: boolean

Defined in: node_modules/graphql/utilities/buildASTSchema.d.mts:14

Set to true to assume the SDL is valid.

Default: false

Inherited from

BaseLoaderOptions.assumeValidSDL


async?

optional async?: boolean

Defined in: packages/loaders/external-fragment/src/options.ts:26 

Whether the default function export should use the asynchronous resolver. Use this with asynchronous loading APIs such as Codegen or loadDocuments. The synchronous loading API cannot consume the Promise returned in async mode. The class loader’s load and loadSync methods select their path explicitly.

Default

false

cacheTTL?

optional cacheTTL?: number

Defined in: packages/loaders/external-fragment/src/options.ts:103 

Time-to-live for cache entries in milliseconds. Set this for long-running processes (e.g. watch mode) so stale entries are automatically evicted. External package maps include parsed sources and are shared by resolver calls; a packageDir package map is not retained unless that package was already cached as an external dependency. Cache configuration is shared by all resolver calls in this module. Calls with a different value recreate all memoized caches, discard their existing entries, and apply the new value to later calls.

Default

Infinity (cache forever)

commentDescriptions?

optional commentDescriptions?: boolean

Defined in: packages/utils/src/Interfaces.ts:150 

Set to true in order to convert all GraphQL comments (marked with # sign) to descriptions (""") GraphQL has built-in support for transforming descriptions to comments (with print), but not while parsing. Turning the flag on will support the other way as well (parse)

Inherited from

BaseLoaderOptions.commentDescriptions


cwd?

optional cwd?: string

Defined in: packages/utils/src/loaders.ts:13 

Inherited from

BaseLoaderOptions.cwd


excludePatterns?

optional excludePatterns?: string[]

Defined in: packages/loaders/external-fragment/src/options.ts:44 

Glob patterns to exclude when scanning packages.

Default

['**/__generated__/**', '**/node_modules/**']

experimentalFragmentVariables?

optional experimentalFragmentVariables?: boolean

Defined in: packages/utils/src/Interfaces.ts:144 

Inherited from

BaseLoaderOptions.experimentalFragmentVariables


extensions?

optional extensions?: string[]

Defined in: packages/loaders/external-fragment/src/options.ts:38 

File extensions to scan for GraphQL fragments (without the dot).

Default

['ts', 'tsx', 'js', 'jsx', 'graphql', 'gql']

externalPackagesDirs

externalPackagesDirs: string[]

Defined in: packages/loaders/external-fragment/src/options.ts:17 

Directories where dependency packages can be found. Each entry is an absolute path to a directory containing package folders.

Example

['/path/to/monorepo/packages', '/path/to/monorepo/libs', '/path/to/node_modules']

fileContentFilter?

optional fileContentFilter?: (content, filePath) => boolean

Defined in: packages/loaders/external-fragment/src/options.ts:79 

Optional predicate to filter which files should be scanned for fragments. Receives the file content as a string. Return true to include the file. Useful to skip code files that don’t use a GraphQL tag or a GraphQL magic comment.

Parameters

content

string

filePath

string

Returns

boolean

Example

(content, filePath) => /\.(graphql|gql)$/.test(filePath) || /\b(?:gql|graphql)\s*`/.test(content) || //\*\s*graphql\s*\*//i.test(content)

ignore?

optional ignore?: string | string[]

Defined in: packages/utils/src/loaders.ts:14 

Inherited from

BaseLoaderOptions.ignore


includeDevDependencies?

optional includeDevDependencies?: boolean

Defined in: packages/loaders/external-fragment/src/options.ts:85 

Whether to include devDependencies when scanning for transitive deps.

Default

true

includeSources?

optional includeSources?: boolean

Defined in: packages/utils/src/loaders.ts:15 

Inherited from

BaseLoaderOptions.includeSources


invalidateTargetPackageCache?

optional invalidateTargetPackageCache?: boolean

Defined in: packages/loaders/external-fragment/src/options.ts:112 

When true, invalidate cached data for the target package specified by packageDir before each resolution call, including its fragment map and package.json dependency metadata. Useful in watch mode to refresh the package being edited while reusing dependency caches.

Default

false

noLocation?

optional noLocation?: boolean

Defined in: packages/utils/src/Interfaces.ts:141 

Inherited from

BaseLoaderOptions.noLocation


packageDependencyFilter?

optional packageDependencyFilter?: (dependencies) => boolean

Defined in: packages/loaders/external-fragment/src/options.ts:67 

Optional filter to decide whether a dependency package should be scanned for GraphQL fragments based on its package.json dependencies. Return true to scan the package.

Unlike packageNameFilter, packages rejected by this filter are still traversed for their own transitive dependencies — they are just not scanned for fragment definitions.

Parameters

dependencies

Record<string, string>

Returns

boolean

Example

(deps) => '@apollo/client' in deps

packageDir

packageDir: string

Defined in: packages/loaders/external-fragment/src/options.ts:9 

Absolute path to the target package directory whose fragments we’re resolving. This is the package that has missing fragment spreads referencing other packages.


packageNameFilter?

optional packageNameFilter?: (packageName) => boolean

Defined in: packages/loaders/external-fragment/src/options.ts:54 

Optional filter function to decide which dependencies from package.json should be considered as potential packages with fragments based on their package name. Return true to include the dependency in the search.

Parameters

packageName

string

Returns

boolean

Default

() => true (all dependencies are considered)

Example

(name) => name.startsWith('my-org-')

pluckConfig?

optional pluckConfig?: GraphQLTagPluckOptions

Defined in: packages/loaders/external-fragment/src/options.ts:90 

Options for graphql-tag-pluck when extracting GraphQL from code files.


scanInternalDirs?

optional scanInternalDirs?: string[]

Defined in: packages/loaders/external-fragment/src/options.ts:32 

Directories within each package to scan for GraphQL fragments.

Default

['src']