/** * Exposes a tagged template literal to parse graphql operation string * "gql" is the only publicly exposed method * @module gql */ import type { DefinitionNode, DocumentNode } from 'graphql/language'; export type AstResolver = (astReference: any) => DocumentNode | undefined; /** * we should look into optimizing this before it turns into a memory hog * weakmaps, or limiting the size of the cache, or something */ export declare const docMap: Map; /** * Opaque reference map to return keys to userland * As a user shouldn't have access to the Document */ export declare const referenceMap: WeakMap; /** * Returns document node if cached or else update the cache and return the document node * @param inputString - operation string * @returns DocumentNode */ export declare function parseDocument(inputString: string): DocumentNode | null; export declare function updateReferenceMapWithKnownKey(doc: DocumentNode, key: object): void; export declare function updateReferenceMapAndGetKey(doc: DocumentNode): object; /** * Insert string and fragment substitutions with the actual nodes * @param inputString * @param substitutions - string | fragment DocumentNode * @returns { operation string, fragment docs [] } */ export declare function processSubstitutions(inputString: ReadonlyArray, substitutions: (string | object)[]): { operationString: string; fragments: DefinitionNode[]; } | null; /** * * @param astReference - ast reference passed from user land */ export declare const astResolver: AstResolver; /** * * @param literals - operation query string * @param subs - all other substitutions * @returns an opaque reference to the parsed document */ export declare function gql(literals: ReadonlyArray | string, ...subs: (string | object)[]): object | null;