UNPKG

@miragejs/graphql

Version:

A library for handling GraphQL requests with Mirage JS

25 lines (24 loc) 1.12 kB
import { GraphQLResolveInfo } from "graphql"; import type Model from "miragejs/lib/orm/model.js"; import type { QueryArgs, ResolverContext } from "../@types/index.js"; type InsertAttrs = { id: string; } & QueryArgs; /** * Resolves mutations in a default way. There are three types of mutations this * library will try to resolve automatically: * * 1. Create. A mutation with one input type argument. * 2. Update. A mutation with two arguments: ID type and input type. * 3. Delete. A mutation with one ID type argument. * * Each of these default mutations will return the affected record. Any * mutations with different arguments, or mutations where the above assumptions * don’t apply, must be resolved by an optional resolver passed into the GraphQL * handler. * * @see {@link https://graphql.org/learn/execution/#root-fields-resolvers} * @throws {Error} If no default resolver can be found for the mutation. */ export declare function resolveMutation(args: QueryArgs, context: ResolverContext, info: GraphQLResolveInfo, typeName: string): Model | Model[] | InsertAttrs | InsertAttrs[]; export {};