import { GraphQLSchema, ObjectTypeDefinitionNode, FieldDefinitionNode, DirectiveNode, GraphQLEnumType, GraphQLInterfaceType, InterfaceTypeDefinitionNode, GraphQLUnionType } from 'graphql'; import { SchemaDirective } from './SchemaDirective'; export declare const DIRECTIVES: SchemaDirective[]; export declare type SchemaNode = ObjectTypeDefinitionNode | FieldDefinitionNode | DirectiveNode; export interface Visitor { /** * Generic visit function for the AST schema traversal. * Only ObjectTypeDefinition and FieldDefinition nodes are included in the path during the * traversal * * May throw validation errors * * @param path: DFS path in the schema tree ending at the directive node of interest */ visit: (path: SchemaNode[]) => void; } export interface Visitors { /** * A map from the node name to the Visitor * * During a DFS traversal of the AST tree if a directive node * name matches the key in the directives map, the corresponding visitor is called */ directives: { [name: string]: Visitor; }; } /** * Parse GraphQL schema * @constructor(schemaPath: string) */ export declare class GraphQLSchemaParser { schema: GraphQLSchema; private _objectTypeDefinations; private namedTypes; constructor(schemaPath: string); private getUnifiedSchema; private static buildPreamble; /** * Read GrapqhQL schema and build a schema from it */ static buildSchema(contents: string): GraphQLSchema; getEnumTypes(): GraphQLEnumType[]; getInterfaceTypes(): GraphQLInterfaceType[]; getUnionTypes(): GraphQLUnionType[]; /** * Get object type definations from the schema. Build-in and scalar types are excluded. */ static createObjectTypeDefinations(schema: GraphQLSchema): ObjectTypeDefinitionNode[]; /** * Returns fields for a given GraphQL object * @param objDefinationNode ObjectTypeDefinitionNode */ getFields(objDefinationNode: ObjectTypeDefinitionNode | InterfaceTypeDefinitionNode): FieldDefinitionNode[]; /** * Returns GraphQL object type definations */ getObjectDefinations(): ObjectTypeDefinitionNode[]; /** * DFS traversal of the AST */ dfsTraversal(visitors: Visitors): void; }