UNPKG

1.65 kBTypeScriptView Raw
1import { GraphQLSchema } from 'graphql';
2import { IExecutableSchemaDefinition } from './types.js';
3/**
4 * Builds a schema from the provided type definitions and resolvers.
5 *
6 * The type definitions are written using Schema Definition Language (SDL). They
7 * can be provided as a string, a `DocumentNode`, a function, or an array of any
8 * of these. If a function is provided, it will be passed no arguments and
9 * should return an array of strings or `DocumentNode`s.
10 *
11 * Note: You can use GraphQL magic comment provide additional syntax
12 * highlighting in your editor (with the appropriate editor plugin).
13 *
14 * ```js
15 * const typeDefs = /* GraphQL *\/ `
16 * type Query {
17 * posts: [Post]
18 * author(id: Int!): Author
19 * }
20 * `;
21 * ```
22 *
23 * The `resolvers` object should be a map of type names to nested object, which
24 * themselves map the type's fields to their appropriate resolvers.
25 * See the [Resolvers](/docs/resolvers) section of the documentation for more details.
26 *
27 * ```js
28 * const resolvers = {
29 * Query: {
30 * posts: (obj, args, ctx, info) => getAllPosts(),
31 * author: (obj, args, ctx, info) => getAuthorById(args.id)
32 * }
33 * };
34 * ```
35 *
36 * Once you've defined both the `typeDefs` and `resolvers`, you can create your
37 * schema:
38 *
39 * ```js
40 * const schema = makeExecutableSchema({
41 * typeDefs,
42 * resolvers,
43 * })
44 * ```
45 */
46export declare function makeExecutableSchema<TContext = any>({ typeDefs, resolvers, resolverValidationOptions, inheritResolversFromInterfaces, updateResolversInPlace, schemaExtensions, defaultFieldResolver, ...otherOptions }: IExecutableSchemaDefinition<TContext>): GraphQLSchema;