/
Group.js
98 lines (87 loc) · 2.45 KB
/
Group.js
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// @flow
import {
resolveCreate,
resolveDelete,
resolveGet,
resolveList,
resolveUpdate
} from "@webiny/commodo-graphql";
const groupFetcher = ctx => ctx.models.SecurityGroup;
export default {
typeDefs: /* GraphQL */ `
type SecurityGroup {
id: ID
name: String
slug: String
createdOn: DateTime
description: String
roles: [SecurityRole]
}
input SecurityGroupInput {
id: ID
name: String
slug: String
description: String
roles: [ID]
}
input SecurityGroupSearchInput {
query: String
fields: [String]
operator: String
}
type SecurityGroupListMeta {
totalCount: Int
totalPages: Int
page: Int
perPage: Int
from: Int
to: Int
previousPage: Int
nextPage: Int
}
type SecurityGroupError {
code: String
message: String
data: JSON
}
type SecurityGroupDeleteResponse {
data: Boolean
error: SecurityGroupError
}
type SecurityGroupResponse {
data: SecurityGroup
error: SecurityGroupError
}
type SecurityGroupListResponse {
data: [SecurityGroup]
meta: SecurityGroupListMeta
error: SecurityGroupError
}
extend type SecurityQuery {
getGroup(id: ID, where: JSON, sort: String): SecurityGroupResponse
listGroups(
page: Int
perPage: Int
where: JSON
sort: JSON
search: SecurityGroupSearchInput
): SecurityGroupListResponse
}
extend type SecurityMutation {
createGroup(data: SecurityGroupInput!): SecurityGroupResponse
updateGroup(id: ID!, data: SecurityGroupInput!): SecurityGroupResponse
deleteGroup(id: ID!): SecurityGroupDeleteResponse
}
`,
resolvers: {
SecurityQuery: {
getGroup: resolveGet(groupFetcher),
listGroups: resolveList(groupFetcher)
},
SecurityMutation: {
createGroup: resolveCreate(groupFetcher),
updateGroup: resolveUpdate(groupFetcher),
deleteGroup: resolveDelete(groupFetcher)
}
}
};