-
Notifications
You must be signed in to change notification settings - Fork 13
/
Mutation.ts
37 lines (34 loc) · 914 Bytes
/
Mutation.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { FetchError } from './FetchError'
import { ResourceQuery, QueryVariables } from './Query'
export type MutationType =
| 'create'
| 'update'
| 'json-patch'
| 'replace'
| 'delete'
export interface MutationData {
[key: string]: any
}
export interface BaseMutation extends ResourceQuery {
type: MutationType
}
export interface CreateMutation extends BaseMutation {
type: 'create'
data: MutationData
}
export interface UpdateMutation extends BaseMutation {
type: 'update' | 'replace' | 'json-patch'
id: string
partial?: boolean
data: MutationData
}
export interface DeleteMutation extends BaseMutation {
type: 'delete'
id: string
}
export type Mutation = CreateMutation | UpdateMutation | DeleteMutation
export interface MutationOptions {
variables?: QueryVariables
onError?: (error: FetchError) => any
onComplete?: (data: any) => any
}