@graphql-tools/schema
- Version 10.0.7
- Published
- 68.4 kB
- 4 dependencies
- MIT license
Install
npm i @graphql-tools/schema
yarn add @graphql-tools/schema
pnpm add @graphql-tools/schema
Overview
A set of utils for faster development of GraphQL tools
Index
Functions
Interfaces
Type Aliases
Functions
function addResolversToSchema
addResolversToSchema: ({ schema, resolvers: inputResolvers, defaultFieldResolver, resolverValidationOptions, inheritResolversFromInterfaces, updateResolversInPlace,}: IAddResolversToSchemaOptions) => GraphQLSchema;
function assertResolversPresent
assertResolversPresent: ( schema: GraphQLSchema, resolverValidationOptions?: IResolverValidationOptions) => void;
function chainResolvers
chainResolvers: <TArgs extends { [argName: string]: any }>( resolvers: Array<Maybe<GraphQLFieldResolver<any, any, TArgs>>>) => (root: any, args: TArgs, ctx: any, info: GraphQLResolveInfo) => any;
function checkForResolveTypeResolver
checkForResolveTypeResolver: ( schema: GraphQLSchema, requireResolversForResolveType?: ValidatorBehavior) => void;
function extendResolversFromInterfaces
extendResolversFromInterfaces: ( schema: GraphQLSchema, resolvers: IResolvers) => IResolvers;
function makeExecutableSchema
makeExecutableSchema: <TContext = any>({ typeDefs, resolvers, resolverValidationOptions, inheritResolversFromInterfaces, updateResolversInPlace, schemaExtensions, defaultFieldResolver, ...otherOptions}: 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 orDocumentNode
s.Note: You can use GraphQL magic comment provide additional syntax highlighting in your editor (with the appropriate editor plugin).
const typeDefs = /* GraphQL *\/ `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](/docs/resolvers) section of the documentation for more details.const resolvers = {Query: {posts: (obj, args, ctx, info) => getAllPosts(),author: (obj, args, ctx, info) => getAuthorById(args.id)}};Once you've defined both the
typeDefs
andresolvers
, you can create your schema:const schema = makeExecutableSchema({typeDefs,resolvers,})
function mergeSchemas
mergeSchemas: (config: MergeSchemasConfig) => GraphQLSchema;
Synchronously merges multiple schemas, typeDefinitions and/or resolvers into a single schema.
Parameter config
Configuration object
Interfaces
interface GraphQLSchemaWithContext
interface GraphQLSchemaWithContext<TContext> extends GraphQLSchema {}
interface IExecutableSchemaDefinition
interface IExecutableSchemaDefinition<TContext = any> extends BuildSchemaOptions, GraphQLParseOptions {}
Configuration object for creating an executable schema
property defaultFieldResolver
defaultFieldResolver?: GraphQLFieldResolver<any, TContext>;
Default field resolver
property inheritResolversFromInterfaces
inheritResolversFromInterfaces?: boolean;
GraphQL object types that implement interfaces will inherit any missing resolvers from their interface types defined in the
resolvers
object
property resolvers
resolvers?: IResolvers<any, TContext> | Array<IResolvers<any, TContext>>;
Object describing the field resolvers for the provided type definitions
property resolverValidationOptions
resolverValidationOptions?: IResolverValidationOptions;
Additional options for validating the provided resolvers
property schemaExtensions
schemaExtensions?: SchemaExtensions | Array<SchemaExtensions>;
Schema extensions
property typeDefs
typeDefs: TypeSource;
The type definitions used to create the schema
property updateResolversInPlace
updateResolversInPlace?: boolean;
Do not create a schema again and use the one from
buildASTSchema
Type Aliases
type MergeSchemasConfig
type MergeSchemasConfig<T = any> = Partial<IExecutableSchemaDefinition<T>> & { /** * The schemas to be merged */ schemas?: GraphQLSchema[];};
Configuration object for schema merging
Package Files (9)
Dependencies (4)
Dev Dependencies (0)
No dev dependencies.
Peer Dependencies (1)
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@graphql-tools/schema
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@graphql-tools/schema)
- HTML<a href="https://www.jsdocs.io/package/@graphql-tools/schema"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 2779 ms. - Missing or incorrect documentation? Open an issue for this package.