Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

GraphQLSchema

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:

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:

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:

const MyAppSchema = new GraphQLSchema({
  ...
  directives: specifiedDirectives.concat([ myCustomDirective ]),
})
class GraphQLSchema {
constructor(config: Readonly<GraphQLSchemaConfig>);
private _directives;
private _implementationsMap;
private _mutationType;
private _queryType;
private _subscriptionType;
private _subTypeMap;
private _typeMap;
__validationErrors: Maybe<ReadonlyArray<GraphQLError>>;
astNode: Maybe<SchemaDefinitionNode>;
description: Maybe<string>;
extensionASTNodes: ReadonlyArray<SchemaExtensionNode>;
extensions: Readonly<GraphQLSchemaExtensions>;
get [Symbol.toStringTag](): string;
 
getDirective(name: string): Maybe<GraphQLDirective>;
getDirectives(): ReadonlyArray<GraphQLDirective>;
getImplementations(interfaceType: GraphQLInterfaceType): {
objects: ReadonlyArray<GraphQLObjectType>;
interfaces: ReadonlyArray<GraphQLInterfaceType>;
}
;
getMutationType(): Maybe<GraphQLObjectType>;
getPossibleTypes(abstractType: GraphQLAbstractType): ReadonlyArray<GraphQLObjectType>;
getQueryType(): Maybe<GraphQLObjectType>;
getRootType(operation: OperationTypeNode): Maybe<GraphQLObjectType>;
getSubscriptionType(): Maybe<GraphQLObjectType>;
getType(name: string): GraphQLNamedType | undefined;
getTypeMap(): TypeMap;
isSubType(abstractType: GraphQLAbstractType, maybeSubType: GraphQLObjectType | GraphQLInterfaceType): boolean;
toConfig(): GraphQLSchemaNormalizedConfig;
}

§Constructors

§
new GraphQLSchema(config: Readonly<GraphQLSchemaConfig>)
[src]

§Properties

§
_directives
[src]
§
_implementationsMap
[src]
§
_mutationType
[src]
§
_queryType
[src]
§
_subscriptionType
[src]
§
_subTypeMap
[src]
§
_typeMap
[src]
§
__validationErrors: Maybe<ReadonlyArray<GraphQLError>>
[src]
§
description: Maybe<string>
[src]
§
extensionASTNodes: ReadonlyArray<SchemaExtensionNode>
[src]
§
extensions: Readonly<GraphQLSchemaExtensions>
[src]
§
[Symbol.toStringTag]: string readonly
[src]

§Methods

§
getDirective(name: string): Maybe<GraphQLDirective>
[src]
§
getDirectives(): ReadonlyArray<GraphQLDirective>
[src]
§
getImplementations(interfaceType: GraphQLInterfaceType): {
objects: ReadonlyArray<GraphQLObjectType>;
interfaces: ReadonlyArray<GraphQLInterfaceType>;
}
[src]
§
getMutationType(): Maybe<GraphQLObjectType>
[src]
§
getPossibleTypes(abstractType: GraphQLAbstractType): ReadonlyArray<GraphQLObjectType>
[src]
§
getQueryType(): Maybe<GraphQLObjectType>
[src]
§
getRootType(operation: OperationTypeNode): Maybe<GraphQLObjectType>
[src]
§
getSubscriptionType(): Maybe<GraphQLObjectType>
[src]
§
getType(name: string): GraphQLNamedType | undefined
[src]
§
getTypeMap(): TypeMap
[src]
§
isSubType(abstractType: GraphQLAbstractType, maybeSubType: GraphQLObjectType | GraphQLInterfaceType): boolean
[src]
§
toConfig(): GraphQLSchemaNormalizedConfig
[src]