UNPKG

1.62 kBTypeScriptView Raw
1import { DefinitionNode, DocumentNode } from 'graphql';
2export declare type VisitedFilesMap = Map<string, Map<string, Set<DefinitionNode>>>;
3/**
4 * Loads the GraphQL document and recursively resolves all the imports
5 * and copies them into the final document.
6 * processImport does not merge the typeDefs as designed ( https://github.com/ardatan/graphql-tools/issues/2980#issuecomment-1003692728 )
7 */
8export declare function processImport(filePath: string, cwd?: string, predefinedImports?: Record<string, string>, visitedFiles?: VisitedFilesMap): DocumentNode;
9export declare function extractDependencies(filePath: string, fileContents: string): {
10 definitionsByName: Map<string, Set<DefinitionNode>>;
11 dependenciesByDefinitionName: Map<string, Set<string>>;
12};
13export declare function processImports(importLines: string[], filePath: string, visitedFiles: VisitedFilesMap, predefinedImports: Record<string, string>): {
14 allImportedDefinitionsMap: Map<string, Set<DefinitionNode>>;
15 potentialTransitiveDefinitionsMap: Map<string, Set<DefinitionNode>>;
16};
17/**
18 * Splits the contents of a GraphQL file into lines that are imports
19 * and other lines which define the actual GraphQL document.
20 */
21export declare function extractImportLines(fileContent: string): {
22 importLines: string[];
23 otherLines: string;
24};
25/**
26 * Parses an import line, returning a list of entities imported and the file
27 * from which they are imported.
28 *
29 * Throws if the import line does not have a correct format.
30 */
31export declare function parseImportLine(importLine: string): {
32 imports: string[];
33 from: string;
34};