UNPKG

@graphql-hive/laboratory

Version:

[Hive](https://the-guild.dev/graphql/hive) is a fully open-source schema registry, analytics, metrics and gateway for [GraphQL federation](https://the-guild.dev/graphql/hive/federation) and other GraphQL APIs.

54 lines (53 loc) 3.61 kB
import { GraphQLObjectType, GraphQLScalarType, GraphQLSchema, OperationTypeNode, GraphQLField, GraphQLOutputType } from 'graphql'; import { Maybe } from 'graphql/jsutils/Maybe'; import { LaboratoryOperation } from './operations'; export declare function healQuery(query: string): string; export declare function isPathInQuery(query: string, path: string, operationName?: string | null): boolean; export declare function addPathToQuery(query: string, path: string, operationName?: string | null): string; export declare function deletePathFromQuery(query: string, path: string, operationName?: string | null): string; export declare function getOperationHash(operation: Pick<LaboratoryOperation, 'query' | 'variables'>): Promise<string | null>; export declare function getOperationName(query: string): string | null | undefined; export declare function getOperationType(query: string): OperationTypeNode | null | undefined; export declare function isArgInQuery(query: string, path: string, argName: string, operationName?: string | null): boolean; export declare function extractOfType(type: GraphQLOutputType): GraphQLObjectType | GraphQLScalarType | null; export declare function findFieldInSchema(path: string, schema: GraphQLSchema): GraphQLField<unknown, unknown, unknown> | null | undefined; export declare function addArgToField(query: string, path: string, argName: string, schema: GraphQLSchema, operationName?: string | null): string; export declare function removeArgFromField(query: string, path: string, argName: string, operationName?: string | null): string; export declare function extractPaths(query: string): string[][]; export declare function getOpenPaths(query: string): string[]; /** * Folds the paths a document implies into the paths the builder already has open. * * Every edit rewrites the document, including a checkbox toggle, so replacing the * open paths outright would throw away whatever the user expanded by hand. Paths the * previous document contributed and this one does not are collapsed; the rest stay. * Returns `current` untouched when nothing moved, so callers can skip a re-render. */ export declare function mergeOpenPaths(current: string[], previousDocumentPaths: string[], documentPaths: string[]): string[]; export type SchemaPathSearchEntry = { path: string; segmentsLower: string[]; pathLower: string; pathWithoutOperationLower: string; }; export type SchemaSearchResult = { matchedPaths: string[]; visiblePaths: Set<string>; forcedOpenPaths: Set<string>; hasMore: boolean; nodesVisited: number; }; export declare function schemaToPaths(schema: GraphQLSchema, maxDepth?: number): string[][]; export declare function pathsToStrings(paths: readonly string[][]): string[]; export declare function createSchemaPathSearchIndex(paths: readonly string[]): SchemaPathSearchEntry[]; export declare function searchSchemaPathIndex(index: readonly SchemaPathSearchEntry[], search: string, limit?: number): string[]; export declare function buildVisiblePathSet(paths: readonly string[]): Set<string>; export declare function buildForcedOpenPathSet(paths: readonly string[]): Set<string>; export declare function searchSchemaPaths(schema: GraphQLSchema, search: string, options?: { maxDepth?: number; maxMatches?: number; maxNodes?: number; operationTypes?: OperationTypeNode[]; }): SchemaSearchResult; export declare function handleTemplate(query: string, env: Record<string, any>): string; export declare function getFieldByPath(path: string, schema: GraphQLSchema): Maybe<GraphQLField<unknown, unknown, unknown>>;