UNPKG

@graphql-inspector/patch

Version:

Applies changes output from @graphql-inspect/diff

20 lines (19 loc) 1.34 kB
import { ASTKindToNode, ASTNode, Kind, NameNode } from 'graphql'; import { Maybe } from 'graphql/jsutils/Maybe'; import { Change } from '@graphql-inspector/core'; import { PatchConfig } from './types.cjs'; export declare function findNamedNode<T extends { readonly name: NameNode; }>(nodes: Maybe<ReadonlyArray<T>>, name: string): T | undefined; export declare function deleteNamedNode<T extends { readonly name: NameNode; }>(nodes: Maybe<ReadonlyArray<T>>, name: string): ReadonlyArray<T> | undefined; export declare function parentPath(path: string): string; export declare function debugPrintChange(change: Change<any>, nodeByPath: Map<string, ASTNode>): void; export declare function assertValueMatch(change: Change<any>, expectedKind: Kind, expected: string | undefined, actual: string | undefined, config: PatchConfig): void; /** * Handles verifying the change object has a path, that the node exists in the * nodeByPath Map, and that the found node is the expected Kind. */ export declare function getChangedNodeOfKind<K extends Kind>(change: Change<any>, nodeByPath: Map<string, ASTNode>, kind: K, config: PatchConfig): ASTKindToNode[K] | void; export declare function getDeletedNodeOfKind<K extends Kind>(change: Change<any>, nodeByPath: Map<string, ASTNode>, kind: K, config: PatchConfig): ASTKindToNode[K] | void;