Skip to main content

@graphql-tools/schema

Type aliases#

Functions#

Type aliases#

ExecutableSchemaTransformation#

Ƭ ExecutableSchemaTransformation: (schema: GraphQLSchema) => GraphQLSchema

Type declaration#

▸ (schema: GraphQLSchema): GraphQLSchema

Parameters#

NameType
schemaGraphQLSchema

Returns: GraphQLSchema

Defined in: packages/schema/src/types.ts:80

Functions#

addCatchUndefinedToSchema#

addCatchUndefinedToSchema(schema: GraphQLSchema): GraphQLSchema

Parameters#

NameType
schemaGraphQLSchema

Returns: GraphQLSchema

Defined in: packages/schema/src/addCatchUndefinedToSchema.ts:15


addErrorLoggingToSchema#

addErrorLoggingToSchema(schema: GraphQLSchema, logger?: ILogger): GraphQLSchema

Parameters#

NameType
schemaGraphQLSchema
logger?ILogger

Returns: GraphQLSchema

Defined in: packages/schema/src/addErrorLoggingToSchema.ts:6


addResolversToSchema#

addResolversToSchema(schemaOrOptions: GraphQLSchema | IAddResolversToSchemaOptions, legacyInputResolvers?: IResolvers, legacyInputValidationOptions?: IResolverValidationOptions): GraphQLSchema

Parameters#

NameType
schemaOrOptionsGraphQLSchema | IAddResolversToSchemaOptions
legacyInputResolvers?IResolvers
legacyInputValidationOptions?IResolverValidationOptions

Returns: GraphQLSchema

Defined in: packages/schema/src/addResolversToSchema.ts:36


addSchemaLevelResolver#

addSchemaLevelResolver(schema: GraphQLSchema, fn: GraphQLFieldResolver<any, any\>): GraphQLSchema

Parameters#

NameType
schemaGraphQLSchema
fnGraphQLFieldResolver<any, any\>

Returns: GraphQLSchema

Defined in: packages/schema/src/addSchemaLevelResolver.ts:9


assertResolversPresent#

assertResolversPresent(schema: GraphQLSchema, resolverValidationOptions?: IResolverValidationOptions): void

Parameters#

NameTypeDefault value
schemaGraphQLSchema-
resolverValidationOptionsIResolverValidationOptions{}

Returns: void

Defined in: packages/schema/src/assertResolversPresent.ts:5


attachDirectiveResolvers#

attachDirectiveResolvers(schema: GraphQLSchema, directiveResolvers: IDirectiveResolvers): GraphQLSchema

Parameters#

NameType
schemaGraphQLSchema
directiveResolversIDirectiveResolvers

Returns: GraphQLSchema

Defined in: packages/schema/src/attachDirectiveResolvers.ts:5


buildDocumentFromTypeDefinitions#

buildDocumentFromTypeDefinitions(typeDefinitions: ITypeDefinitions, parseOptions?: GraphQLParseOptions): DocumentNode

Parameters#

NameType
typeDefinitionsITypeDefinitions
parseOptions?GraphQLParseOptions

Returns: DocumentNode

Defined in: packages/schema/src/buildSchemaFromTypeDefinitions.ts:31


buildSchemaFromTypeDefinitions#

buildSchemaFromTypeDefinitions(typeDefinitions: ITypeDefinitions, parseOptions?: GraphQLParseOptions, noExtensionExtraction?: boolean): GraphQLSchema

Parameters#

NameType
typeDefinitionsITypeDefinitions
parseOptions?GraphQLParseOptions
noExtensionExtraction?boolean

Returns: GraphQLSchema

Defined in: packages/schema/src/buildSchemaFromTypeDefinitions.ts:8


chainResolvers#

chainResolvers(resolvers: GraphQLFieldResolver<any, any\>[]): function

Parameters#

NameType
resolversGraphQLFieldResolver<any, any\>[]

Returns: (root: any, args: { [argName: string]: any; }, ctx: any, info: GraphQLResolveInfo) => any

Defined in: packages/schema/src/chainResolvers.ts:3


checkForResolveTypeResolver#

checkForResolveTypeResolver(schema: GraphQLSchema, requireResolversForResolveType: ValidatorBehavior): void

Parameters#

NameType
schemaGraphQLSchema
requireResolversForResolveTypeValidatorBehavior

Returns: void

Defined in: packages/schema/src/checkForResolveTypeResolver.ts:6


concatenateTypeDefs#

concatenateTypeDefs(typeDefinitionsAry: ITypedef[], calledFunctionRefs?: Set<ITypedef\>): string

Parameters#

NameType
typeDefinitionsAryITypedef[]
calledFunctionRefsSet<ITypedef\>

Returns: string

Defined in: packages/schema/src/concatenateTypeDefs.ts:5


decorateWithLogger#

decorateWithLogger(fn: GraphQLFieldResolver<any, any\>, logger: ILogger, hint: string): GraphQLFieldResolver<any, any\>

Parameters#

NameType
fnGraphQLFieldResolver<any, any\>
loggerILogger
hintstring

Returns: GraphQLFieldResolver<any, any\>

Defined in: packages/schema/src/decorateWithLogger.ts:9


extendResolversFromInterfaces#

extendResolversFromInterfaces(schema: GraphQLSchema, resolvers: IResolvers): IResolvers

Parameters#

NameType
schemaGraphQLSchema
resolversIResolvers

Returns: IResolvers

Defined in: packages/schema/src/extendResolversFromInterfaces.ts:5


extractExtensionDefinitions#

extractExtensionDefinitions(ast: DocumentNode): object

Parameters#

NameType
astDocumentNode

Returns: object

NameType
definitionsDefinitionNode[]
kind"Document"
loc?Location

Defined in: packages/schema/src/extensionDefinitions.ts:40


filterAndExtractExtensionDefinitions#

filterAndExtractExtensionDefinitions(ast: DocumentNode): object

Parameters#

NameType
astDocumentNode

Returns: object

NameType
extensionsAstobject
extensionsAst.definitionsDefinitionNode[]
extensionsAst.kind"Document"
extensionsAst.loc?Location
typesAstobject
typesAst.definitionsDefinitionNode[]
typesAst.kind"Document"
typesAst.loc?Location

Defined in: packages/schema/src/extensionDefinitions.ts:12


filterExtensionDefinitions#

filterExtensionDefinitions(ast: DocumentNode): object

Parameters#

NameType
astDocumentNode

Returns: object

NameType
definitionsDefinitionNode[]
kind"Document"
loc?Location

Defined in: packages/schema/src/extensionDefinitions.ts:35


makeExecutableSchema#

makeExecutableSchema<TContext\>(__namedParameters: IExecutableSchemaDefinition<TContext\>): GraphQLSchema

Builds a schema from the provided type definitions and resolvers.

The type definitions are written using Schema Definition Language (SDL). They can be provided as a string, a DocumentNode, a function, or an array of any of these. If a function is provided, it will be passed no arguments and should return an array of strings or DocumentNodes.

Note: You can use graphql-tag to not only parse a string into a DocumentNode but also to provide additional syntax highlighting in your editor (with the appropriate editor plugin).

const typeDefs = gql`
type Query {
posts: [Post]
author(id: Int!): Author
}
`;

The resolvers object should be a map of type names to nested object, which themselves map the type's fields to their appropriate resolvers. See the Resolvers section of the documentation for more details.

const resolvers = {
Query: {
posts: (obj, args, ctx, info) =&gt; getAllPosts(),
author: (obj, args, ctx, info) =&gt; getAuthorById(args.id)
}
};

Once you've defined both the typeDefs and resolvers, you can create your schema:

const schema = makeExecutableSchema({
typeDefs,
resolvers,
})

Type parameters#

NameDefault
TContextany

Parameters#

NameType
__namedParametersIExecutableSchemaDefinition<TContext\>

Returns: GraphQLSchema

Defined in: packages/schema/src/makeExecutableSchema.ts:58