import type { Maybe } from '../jsutils/Maybe'; import type { ObjMap } from '../jsutils/ObjMap'; import type { GraphQLError } from '../error/GraphQLError'; import type { SchemaDefinitionNode, SchemaExtensionNode, } from '../language/ast'; import { OperationTypeNode } from '../language/ast'; import type { GraphQLAbstractType, GraphQLInterfaceType, GraphQLNamedType, GraphQLObjectType, } from './definition'; import type { GraphQLDirective } from './directives'; /** * Test if the given value is a GraphQL schema. */ export declare function isSchema(schema: unknown): schema is GraphQLSchema; export declare function assertSchema(schema: unknown): GraphQLSchema; /** * Custom extensions * * @remarks * Use a unique identifier name for your extension, for example the name of * your library or project. Do not use a shortened identifier as this increases * the risk of conflicts. We recommend you add at most one extension field, * an object which can contain all the values you need. */ export interface GraphQLSchemaExtensions { [attributeName: string]: unknown; } /** * Schema Definition * * A Schema is created by supplying the root types of each type of operation, * query and mutation (optional). A schema definition is then supplied to the * validator and executor. * * Example: * * ```ts * const MyAppSchema = new GraphQLSchema({ * query: MyAppQueryRootType, * mutation: MyAppMutationRootType, * }) * ``` * * Note: When the schema is constructed, by default only the types that are * reachable by traversing the root types are included, other types must be * explicitly referenced. * * Example: * * ```ts * const characterInterface = new GraphQLInterfaceType({ * name: 'Character', * ... * }); * * const humanType = new GraphQLObjectType({ * name: 'Human', * interfaces: [characterInterface], * ... * }); * * const droidType = new GraphQLObjectType({ * name: 'Droid', * interfaces: [characterInterface], * ... * }); * * const schema = new GraphQLSchema({ * query: new GraphQLObjectType({ * name: 'Query', * fields: { * hero: { type: characterInterface, ... }, * } * }), * ... * // Since this schema references only the `Character` interface it's * // necessary to explicitly list the types that implement it if * // you want them to be included in the final schema. * types: [humanType, droidType], * }) * ``` * * Note: If an array of `directives` are provided to GraphQLSchema, that will be * the exact list of directives represented and allowed. If `directives` is not * provided then a default set of the specified directives (e.g. `@include` and * `@skip`) will be used. If you wish to provide *additional* directives to these * specified directives, you must explicitly declare them. Example: * * ```ts * const MyAppSchema = new GraphQLSchema({ * ... * directives: specifiedDirectives.concat([ myCustomDirective ]), * }) * ``` */ export declare class GraphQLSchema { description: Maybe; extensions: Readonly; astNode: Maybe; extensionASTNodes: ReadonlyArray; __validationErrors: Maybe>; private _queryType; private _mutationType; private _subscriptionType; private _directives; private _typeMap; private _subTypeMap; private _implementationsMap; constructor(config: Readonly); get [Symbol.toStringTag](): string; getQueryType(): Maybe; getMutationType(): Maybe; getSubscriptionType(): Maybe; getRootType(operation: OperationTypeNode): Maybe; getTypeMap(): TypeMap; getType(name: string): GraphQLNamedType | undefined; getPossibleTypes( abstractType: GraphQLAbstractType, ): ReadonlyArray; getImplementations(interfaceType: GraphQLInterfaceType): { objects: ReadonlyArray; interfaces: ReadonlyArray; }; isSubType( abstractType: GraphQLAbstractType, maybeSubType: GraphQLObjectType | GraphQLInterfaceType, ): boolean; getDirectives(): ReadonlyArray; getDirective(name: string): Maybe; toConfig(): GraphQLSchemaNormalizedConfig; } declare type TypeMap = ObjMap; export interface GraphQLSchemaValidationOptions { /** * When building a schema from a GraphQL service's introspection result, it * might be safe to assume the schema is valid. Set to true to assume the * produced schema is valid. * * Default: false */ assumeValid?: boolean; } export interface GraphQLSchemaConfig extends GraphQLSchemaValidationOptions { description?: Maybe; query?: Maybe; mutation?: Maybe; subscription?: Maybe; types?: Maybe>; directives?: Maybe>; extensions?: Maybe>; astNode?: Maybe; extensionASTNodes?: Maybe>; } /** * @internal */ export interface GraphQLSchemaNormalizedConfig extends GraphQLSchemaConfig { description: Maybe; types: ReadonlyArray; directives: ReadonlyArray; extensions: Readonly; extensionASTNodes: ReadonlyArray; assumeValid: boolean; } export {};