1 | import { GraphQLSchema } from 'graphql';
|
2 | import { IExecutableSchemaDefinition } from './types';
|
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-tag` to not only parse a string into a
|
12 | * `DocumentNode` but also to provide additional syntax highlighting in your
|
13 | * editor (with the appropriate editor plugin).
|
14 | *
|
15 | * ```js
|
16 | * const typeDefs = gql`
|
17 | * type Query {
|
18 | * posts: [Post]
|
19 | * author(id: Int!): Author
|
20 | * }
|
21 | * `;
|
22 | * ```
|
23 | *
|
24 | * The `resolvers` object should be a map of type names to nested object, which
|
25 | * themselves map the type's fields to their appropriate resolvers.
|
26 | * See the [Resolvers](/docs/resolvers) section of the documentation for more details.
|
27 | *
|
28 | * ```js
|
29 | * const resolvers = {
|
30 | * Query: {
|
31 | * posts: (obj, args, ctx, info) => getAllPosts(),
|
32 | * author: (obj, args, ctx, info) => getAuthorById(args.id)
|
33 | * }
|
34 | * };
|
35 | * ```
|
36 | *
|
37 | * Once you've defined both the `typeDefs` and `resolvers`, you can create your
|
38 | * schema:
|
39 | *
|
40 | * ```js
|
41 | * const schema = makeExecutableSchema({
|
42 | * typeDefs,
|
43 | * resolvers,
|
44 | * })
|
45 | * ```
|
46 | */
|
47 | export declare function makeExecutableSchema<TContext = any>({ typeDefs, resolvers, resolverValidationOptions, parseOptions, inheritResolversFromInterfaces, pruningOptions, updateResolversInPlace, schemaExtensions, }: IExecutableSchemaDefinition<TContext>): GraphQLSchema;
|