-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetMutationObjectType.js
More file actions
34 lines (33 loc) · 970 Bytes
/
getMutationObjectType.js
File metadata and controls
34 lines (33 loc) · 970 Bytes
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
import {
GraphQLObjectType,
GraphQLBoolean,
GraphQLList,
GraphQLString,
getErrorType,
key
} from './'
export default function getMutationObjectType(ObjectType, options = {fields: {}, errorFields: {}}) {
return ObjectType._typeMutation || (ObjectType._typeMutation = new GraphQLObjectType({
name: `${ObjectType.name}Mutation`,
fields: Object.assign(
{
[key(ObjectType.name)]: {
type: ObjectType
},
erred: {
type: GraphQLBoolean
},
errors: {
type: getErrorType(ObjectType, options.errorFields || {})
},
changed: {
type: GraphQLBoolean
},
changes: {
type: new GraphQLList(GraphQLString)
}
},
options.fields || {}
)
}))
}