UNPKG

2.16 kBTypeScriptView Raw
1import type { Maybe } from '../jsutils/Maybe';
2import type { ASTNode, FieldNode } from '../language/ast';
3import type { ASTVisitor } from '../language/visitor';
4import type {
5 GraphQLArgument,
6 GraphQLCompositeType,
7 GraphQLEnumValue,
8 GraphQLField,
9 GraphQLInputType,
10 GraphQLOutputType,
11 GraphQLType,
12} from '../type/definition';
13import type { GraphQLDirective } from '../type/directives';
14import type { GraphQLSchema } from '../type/schema';
15/**
16 * TypeInfo is a utility class which, given a GraphQL schema, can keep track
17 * of the current field and type definitions at any point in a GraphQL document
18 * AST during a recursive descent by calling `enter(node)` and `leave(node)`.
19 */
20export declare class TypeInfo {
21 private _schema;
22 private _typeStack;
23 private _parentTypeStack;
24 private _inputTypeStack;
25 private _fieldDefStack;
26 private _defaultValueStack;
27 private _directive;
28 private _argument;
29 private _enumValue;
30 private _getFieldDef;
31 constructor(
32 schema: GraphQLSchema,
33 /**
34 * Initial type may be provided in rare cases to facilitate traversals
35 * beginning somewhere other than documents.
36 */
37 initialType?: Maybe<GraphQLType>,
38 /** @deprecated will be removed in 17.0.0 */
39 getFieldDefFn?: GetFieldDefFn,
40 );
41 get [Symbol.toStringTag](): string;
42 getType(): Maybe<GraphQLOutputType>;
43 getParentType(): Maybe<GraphQLCompositeType>;
44 getInputType(): Maybe<GraphQLInputType>;
45 getParentInputType(): Maybe<GraphQLInputType>;
46 getFieldDef(): Maybe<GraphQLField<unknown, unknown>>;
47 getDefaultValue(): Maybe<unknown>;
48 getDirective(): Maybe<GraphQLDirective>;
49 getArgument(): Maybe<GraphQLArgument>;
50 getEnumValue(): Maybe<GraphQLEnumValue>;
51 enter(node: ASTNode): void;
52 leave(node: ASTNode): void;
53}
54declare type GetFieldDefFn = (
55 schema: GraphQLSchema,
56 parentType: GraphQLType,
57 fieldNode: FieldNode,
58) => Maybe<GraphQLField<unknown, unknown>>;
59/**
60 * Creates a new visitor instance which maintains a provided TypeInfo instance
61 * along with visiting visitor.
62 */
63export declare function visitWithTypeInfo(
64 typeInfo: TypeInfo,
65 visitor: ASTVisitor,
66): ASTVisitor;
67export {};