@graphql-inspector/patch
Version:
Applies changes output from @graphql-inspect/diff
18 lines (17 loc) • 1.21 kB
TypeScript
import { ASTNode, DocumentNode, GraphQLSchema } from 'graphql';
import { Change } from '@graphql-inspector/core';
import { PatchConfig, SchemaNode } from './types.js';
export * as errors from './errors.js';
/**
* Wraps converting a schema to AST safely, patching, then rebuilding the schema from AST.
* The schema is not validated in this function. That it is the responsibility of the caller.
*/
export declare function patchSchema(schema: GraphQLSchema, changes: Change<any>[], config?: Partial<PatchConfig>): GraphQLSchema;
/**
* Extracts all the root definitions from a DocumentNode and creates a mapping of their coordinate
* to the defined ASTNode. E.g. A field's coordinate is "Type.field".
*/
export declare function groupByCoordinateAST(ast: DocumentNode): [SchemaNode[], Map<string, ASTNode>];
export declare function patchCoordinatesAST(schemaNodes: SchemaNode[], nodesByCoordinate: Map<string, ASTNode>, changes: Change<any>[], patchConfig?: Partial<PatchConfig>): DocumentNode;
/** This method wraps groupByCoordinateAST and patchCoordinatesAST for convenience. */
export declare function patch(ast: DocumentNode, changes: Change<any>[], patchConfig?: Partial<PatchConfig>): DocumentNode;