UNPKG

1.61 kBTypeScriptView Raw
1import type {
2 GraphQLFieldConfig,
3 GraphQLFieldExtensions,
4 GraphQLInputFieldConfig,
5 GraphQLResolveInfo,
6 ThunkObjMap,
7} from 'graphql';
8declare type MutationFn<TInput = any, TOutput = unknown, TContext = any> = (
9 object: TInput,
10 ctx: TContext,
11 info: GraphQLResolveInfo,
12) => TOutput;
13/**
14 * A description of a mutation consumable by mutationWithClientMutationId
15 * to create a GraphQLFieldConfig for that mutation.
16 *
17 * The inputFields and outputFields should not include `clientMutationId`,
18 * as this will be provided automatically.
19 *
20 * An input object will be created containing the input fields, and an
21 * object will be created containing the output fields.
22 *
23 * mutateAndGetPayload will receive an Object with a key for each
24 * input field, and it should return an Object with a key for each
25 * output field. It may return synchronously, or return a Promise.
26 */
27interface MutationConfig<TInput = any, TOutput = unknown, TContext = any> {
28 name: string;
29 description?: string;
30 deprecationReason?: string;
31 extensions?: GraphQLFieldExtensions<any, any>;
32 inputFields: ThunkObjMap<GraphQLInputFieldConfig>;
33 outputFields: ThunkObjMap<GraphQLFieldConfig<TOutput, TContext>>;
34 mutateAndGetPayload: MutationFn<TInput, Promise<TOutput> | TOutput, TContext>;
35}
36/**
37 * Returns a GraphQLFieldConfig for the mutation described by the
38 * provided MutationConfig.
39 */
40export declare function mutationWithClientMutationId<
41 TInput = any,
42 TOutput = unknown,
43 TContext = any,
44>(
45 config: MutationConfig<TInput, TOutput, TContext>,
46): GraphQLFieldConfig<unknown, TContext>;
47export {};