UNPKG

1.72 kBTypeScriptView Raw
1import { Types } from '@graphql-codegen/plugin-helpers';
2import { ImportSource, FragmentImport, ImportDeclaration, LoadedFragment } from '@graphql-codegen/visitor-plugin-common';
3import { FragmentDefinitionNode, GraphQLSchema } from 'graphql';
4import { Source } from '@graphql-tools/utils';
5export declare type FragmentRegistry = {
6 [fragmentName: string]: {
7 location: string;
8 importNames: string[];
9 onType: string;
10 node: FragmentDefinitionNode;
11 };
12};
13export declare type DocumentImportResolverOptions = {
14 baseDir: string;
15 /**
16 * Generates a target file path from the source `document.location`
17 */
18 generateFilePath: (location: string) => string;
19 /**
20 * Schema base types source
21 */
22 schemaTypesSource: string | ImportSource;
23 /**
24 * Should `import type` be used
25 */
26 typesImport: boolean;
27};
28interface ResolveDocumentImportResult {
29 filename: string;
30 documents: [Source];
31 importStatements: string[];
32 fragmentImports: ImportDeclaration<FragmentImport>[];
33 externalFragments: LoadedFragment<{
34 level: number;
35 }>[];
36}
37/**
38 * Transform the preset's provided documents into single-file generator sources, while resolving fragment and user-defined imports
39 *
40 * Resolves user provided imports and fragment imports using the `DocumentImportResolverOptions`.
41 * Does not define specific plugins, but rather returns a string[] of `importStatements` for the calling plugin to make use of
42 */
43export declare function resolveDocumentImports<T>(presetOptions: Types.PresetFnArgs<T>, schemaObject: GraphQLSchema, importResolverOptions: DocumentImportResolverOptions): Array<ResolveDocumentImportResult>;
44export {};