import { GraphQLSchema } from "https://dotland.deno.dev/x/graphql_deno@v15.0.0/lib/type/index.js";
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
Methods
getDirective(name)
getImplementations(interfaceType)
getPossibleTypes(abstractType)
getType(name)
isPossibleType(abstractType, possibleType)
isSubType(abstractType, maybeSubType)
toConfig()