47 lines
1.7 KiB
TypeScript
47 lines
1.7 KiB
TypeScript
import { IExecutableSchemaDefinition } from './types';
|
|
/**
|
|
* 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 `DocumentNode`s.
|
|
*
|
|
* 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).
|
|
*
|
|
* ```js
|
|
* 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](/docs/resolvers) section of the documentation for more details.
|
|
*
|
|
* ```js
|
|
* const resolvers = {
|
|
* Query: {
|
|
* posts: (obj, args, ctx, info) => getAllPosts(),
|
|
* author: (obj, args, ctx, info) => getAuthorById(args.id)
|
|
* }
|
|
* };
|
|
* ```
|
|
*
|
|
* Once you've defined both the `typeDefs` and `resolvers`, you can create your
|
|
* schema:
|
|
*
|
|
* ```js
|
|
* const schema = makeExecutableSchema({
|
|
* typeDefs,
|
|
* resolvers,
|
|
* })
|
|
* ```
|
|
*/
|
|
export declare function makeExecutableSchema<TContext = any>({ typeDefs, resolvers, logger, allowUndefinedInResolve, resolverValidationOptions, directiveResolvers, schemaDirectives, schemaTransforms: userProvidedSchemaTransforms, parseOptions, inheritResolversFromInterfaces, pruningOptions, updateResolversInPlace, noExtensionExtraction, }: IExecutableSchemaDefinition<TContext>): import("graphql").GraphQLSchema;
|