@projectcaluma/ember-testing 11.0.0-beta.3 → 11.0.0-beta.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +86 -0
- package/addon/mirage-graphql/deserialize.js +13 -0
- package/addon/mirage-graphql/filters/answer.js +5 -7
- package/addon/mirage-graphql/filters/base.js +42 -24
- package/addon/mirage-graphql/filters/form.js +5 -1
- package/addon/mirage-graphql/filters/index.js +17 -0
- package/addon/mirage-graphql/filters/question.js +1 -1
- package/addon/mirage-graphql/filters/work-item.js +11 -11
- package/addon/mirage-graphql/index.js +59 -63
- package/addon/mirage-graphql/mocks/answer.js +6 -6
- package/addon/mirage-graphql/mocks/base.js +14 -11
- package/addon/mirage-graphql/mocks/form.js +2 -2
- package/addon/mirage-graphql/mocks/index.js +17 -0
- package/addon/mirage-graphql/mocks/question.js +5 -5
- package/addon/mirage-graphql/mocks/work-item.js +62 -10
- package/addon/mirage-graphql/register.js +20 -0
- package/addon/mirage-graphql/schema.graphql +763 -1889
- package/addon/mirage-graphql/serialize.js +14 -0
- package/addon/scenarios/distribution.js +91 -12
- package/addon-mirage-support/factories/answer.js +13 -8
- package/addon-mirage-support/factories/case.js +1 -1
- package/addon-mirage-support/factories/document.js +2 -0
- package/addon-mirage-support/factories/file.js +1 -1
- package/addon-mirage-support/factories/form.js +5 -0
- package/addon-mirage-support/factories/work-item.js +2 -1
- package/addon-mirage-support/models/task.js +1 -0
- package/package.json +20 -21
- package/addon/mirage-graphql/handler.js +0 -60
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { classify } from "@ember/string";
|
|
2
|
+
|
|
3
|
+
export default function serialize(deserialized = {}, type) {
|
|
4
|
+
const __typename = [deserialized.type?.toLowerCase(), type]
|
|
5
|
+
.filter(Boolean)
|
|
6
|
+
.map(classify)
|
|
7
|
+
.join("");
|
|
8
|
+
|
|
9
|
+
return {
|
|
10
|
+
...deserialized,
|
|
11
|
+
id: btoa(`${__typename}:${deserialized.id}`),
|
|
12
|
+
__typename,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -2,8 +2,16 @@ import { faker } from "@faker-js/faker";
|
|
|
2
2
|
import { DateTime } from "luxon";
|
|
3
3
|
|
|
4
4
|
export function createBlueprint(server) {
|
|
5
|
-
const inquiryForm = server.create("form", {
|
|
6
|
-
|
|
5
|
+
const inquiryForm = server.create("form", {
|
|
6
|
+
name: "Inquiry",
|
|
7
|
+
slug: "inquiry",
|
|
8
|
+
isPublished: false,
|
|
9
|
+
});
|
|
10
|
+
const inquiryAnswerForm = server.create("form", {
|
|
11
|
+
name: "Inquiry answer",
|
|
12
|
+
slug: "inquiry-answer",
|
|
13
|
+
isPublished: false,
|
|
14
|
+
});
|
|
7
15
|
|
|
8
16
|
server.create("question", {
|
|
9
17
|
slug: "inquiry-remark",
|
|
@@ -52,13 +60,27 @@ export function createBlueprint(server) {
|
|
|
52
60
|
type: "TEXTAREA",
|
|
53
61
|
formIds: [inquiryAnswerForm.id],
|
|
54
62
|
});
|
|
63
|
+
server.create("question", {
|
|
64
|
+
slug: "inquiry-answer-hint",
|
|
65
|
+
isRequired: "false",
|
|
66
|
+
maxLength: 9999,
|
|
67
|
+
minLength: 0,
|
|
68
|
+
label: "Hint",
|
|
69
|
+
type: "TEXTAREA",
|
|
70
|
+
formIds: [inquiryAnswerForm.id],
|
|
71
|
+
});
|
|
55
72
|
|
|
56
73
|
server.create("workflow", { slug: "distribution" });
|
|
57
74
|
server.create("workflow", { slug: "inquiry" });
|
|
58
75
|
|
|
76
|
+
server.create("task", { slug: "distribution" });
|
|
59
77
|
server.create("task", { slug: "create-inquiry" });
|
|
60
78
|
server.create("task", { slug: "complete-distribution" });
|
|
61
|
-
server.create("task", {
|
|
79
|
+
server.create("task", {
|
|
80
|
+
slug: "inquiry",
|
|
81
|
+
formId: inquiryForm.id,
|
|
82
|
+
type: "COMPLETE_TASK_FORM",
|
|
83
|
+
});
|
|
62
84
|
server.create("task", {
|
|
63
85
|
slug: "compose-inquiry-answer",
|
|
64
86
|
type: "COMPLETE_WORKFLOW_FORM",
|
|
@@ -69,6 +91,7 @@ export function createBlueprint(server) {
|
|
|
69
91
|
slug: "adjust-inquiry-answer",
|
|
70
92
|
type: "COMPLETE_WORKFLOW_FORM",
|
|
71
93
|
});
|
|
94
|
+
server.create("task", { slug: "check-inquiries" });
|
|
72
95
|
}
|
|
73
96
|
|
|
74
97
|
export function createInquiry(
|
|
@@ -77,7 +100,10 @@ export function createInquiry(
|
|
|
77
100
|
{ from, to, remark, deadline },
|
|
78
101
|
workItemAttrs = {}
|
|
79
102
|
) {
|
|
80
|
-
const document = server.create("document", {
|
|
103
|
+
const document = server.create("document", {
|
|
104
|
+
formId: "inquiry",
|
|
105
|
+
modifiedContentByUser: "1",
|
|
106
|
+
});
|
|
81
107
|
|
|
82
108
|
server.create("answer", {
|
|
83
109
|
document,
|
|
@@ -102,11 +128,20 @@ export function createInquiry(
|
|
|
102
128
|
});
|
|
103
129
|
}
|
|
104
130
|
|
|
131
|
+
export function withdrawInquiry(server, { inquiry }) {
|
|
132
|
+
inquiry.update({ status: "CANCELED" });
|
|
133
|
+
|
|
134
|
+
return inquiry;
|
|
135
|
+
}
|
|
136
|
+
|
|
105
137
|
export function sendInquiry(server, { inquiry }) {
|
|
106
138
|
const childCase = server.create("case", {
|
|
107
139
|
status: "RUNNING",
|
|
108
140
|
workflowId: "inquiry",
|
|
109
|
-
document: server.create("document", {
|
|
141
|
+
document: server.create("document", {
|
|
142
|
+
formId: "inquiry-answer",
|
|
143
|
+
modifiedContentByUser: "1",
|
|
144
|
+
}),
|
|
110
145
|
});
|
|
111
146
|
|
|
112
147
|
server.create("work-item", {
|
|
@@ -121,7 +156,7 @@ export function sendInquiry(server, { inquiry }) {
|
|
|
121
156
|
return inquiry;
|
|
122
157
|
}
|
|
123
158
|
|
|
124
|
-
export function answerInquiry(server, { inquiry, status, reason }) {
|
|
159
|
+
export function answerInquiry(server, { inquiry, status, reason, hint }) {
|
|
125
160
|
if (inquiry.status !== "READY") {
|
|
126
161
|
inquiry = sendInquiry(server, { inquiry });
|
|
127
162
|
}
|
|
@@ -135,7 +170,12 @@ export function answerInquiry(server, { inquiry, status, reason }) {
|
|
|
135
170
|
server.create("answer", {
|
|
136
171
|
document: inquiry.childCase.document,
|
|
137
172
|
questionId: "inquiry-answer-reason",
|
|
138
|
-
value: reason ?? faker.lorem.
|
|
173
|
+
value: reason ?? faker.lorem.paragraphs(3, "\n\n"),
|
|
174
|
+
});
|
|
175
|
+
server.create("answer", {
|
|
176
|
+
document: inquiry.childCase.document,
|
|
177
|
+
questionId: "inquiry-answer-hint",
|
|
178
|
+
value: hint ?? faker.lorem.paragraph(),
|
|
139
179
|
});
|
|
140
180
|
|
|
141
181
|
inquiry.childCase.workItems
|
|
@@ -157,8 +197,8 @@ export function answerInquiry(server, { inquiry, status, reason }) {
|
|
|
157
197
|
return inquiry;
|
|
158
198
|
}
|
|
159
199
|
|
|
160
|
-
export function confirmInquiry({ inquiry }) {
|
|
161
|
-
inquiry.update({ status: "COMPLETED" });
|
|
200
|
+
export function confirmInquiry(server, { inquiry }) {
|
|
201
|
+
inquiry.update({ status: "COMPLETED", isRedoable: true });
|
|
162
202
|
inquiry.childCase.update({
|
|
163
203
|
status: "COMPLETED",
|
|
164
204
|
closedAt: faker.date.recent(),
|
|
@@ -170,6 +210,21 @@ export function confirmInquiry({ inquiry }) {
|
|
|
170
210
|
.filter((workItem) => workItem.taskId === "revise-inquiry-answer")
|
|
171
211
|
.update({ status: "CANCELED" });
|
|
172
212
|
|
|
213
|
+
if (
|
|
214
|
+
!inquiry.case.workItems.filter(
|
|
215
|
+
(workItem) =>
|
|
216
|
+
workItem.taskId === "check-inquiries" &&
|
|
217
|
+
String(workItem.addressedGroups) === String(inquiry.addressedGroups)
|
|
218
|
+
).length
|
|
219
|
+
) {
|
|
220
|
+
server.create("work-item", {
|
|
221
|
+
taskId: "check-inquiries",
|
|
222
|
+
status: "READY",
|
|
223
|
+
case: inquiry.case,
|
|
224
|
+
addressedGroups: inquiry.addressedGroups,
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
|
|
173
228
|
return inquiry;
|
|
174
229
|
}
|
|
175
230
|
|
|
@@ -191,10 +246,17 @@ export function reviseInquiry(server, { inquiry }) {
|
|
|
191
246
|
}
|
|
192
247
|
|
|
193
248
|
export function createCase(server, { group }) {
|
|
249
|
+
const distributionWorkItem = server.create("work-item", {
|
|
250
|
+
taskId: "distribution",
|
|
251
|
+
status: "READY",
|
|
252
|
+
case: server.create("case"),
|
|
253
|
+
});
|
|
254
|
+
|
|
194
255
|
const distributionCase = server.create("case", {
|
|
195
256
|
id: "4222ab21-9c89-47de-98be-d62a8ed0ebeb",
|
|
196
257
|
status: "RUNNING",
|
|
197
258
|
workflowId: "distribution",
|
|
259
|
+
parentWorkItem: distributionWorkItem,
|
|
198
260
|
});
|
|
199
261
|
|
|
200
262
|
server.create("work-item", {
|
|
@@ -224,15 +286,22 @@ export default function (server, groups) {
|
|
|
224
286
|
const g4 = groups[4];
|
|
225
287
|
|
|
226
288
|
const create = (...args) => createInquiry(server, distributionCase, ...args);
|
|
289
|
+
const withdraw = (...args) => withdrawInquiry(server, ...args);
|
|
227
290
|
const send = (...args) => sendInquiry(server, ...args);
|
|
228
291
|
const answer = (...args) => answerInquiry(server, ...args);
|
|
229
|
-
const confirm = (...args) => confirmInquiry(...args);
|
|
292
|
+
const confirm = (...args) => confirmInquiry(server, ...args);
|
|
230
293
|
const revise = (...args) => reviseInquiry(server, ...args);
|
|
231
294
|
|
|
232
295
|
const distributionCase = createCase(server, { group: g });
|
|
233
296
|
|
|
234
297
|
// controlling
|
|
235
|
-
create({ from: g, to: g1 });
|
|
298
|
+
create({ from: g, to: g1 }, { id: "d570dfc3-0df7-4276-8735-892be011923c" });
|
|
299
|
+
withdraw({
|
|
300
|
+
inquiry: create(
|
|
301
|
+
{ from: g, to: g2 },
|
|
302
|
+
{ id: "4afed640-07a6-4eb9-82a7-b5e961391370" }
|
|
303
|
+
),
|
|
304
|
+
});
|
|
236
305
|
send({
|
|
237
306
|
inquiry: create(
|
|
238
307
|
{
|
|
@@ -240,7 +309,7 @@ export default function (server, groups) {
|
|
|
240
309
|
to: g2,
|
|
241
310
|
deadline: faker.date.past(),
|
|
242
311
|
},
|
|
243
|
-
{ id: "6bbdc36a-3174-4578-93d4-0cb84d3dab97" }
|
|
312
|
+
{ id: "6bbdc36a-3174-4578-93d4-0cb84d3dab97", meta: {} }
|
|
244
313
|
),
|
|
245
314
|
});
|
|
246
315
|
confirm({
|
|
@@ -271,6 +340,14 @@ export default function (server, groups) {
|
|
|
271
340
|
}),
|
|
272
341
|
});
|
|
273
342
|
|
|
343
|
+
// withdrawn inquiry, should not be visible anywhere
|
|
344
|
+
withdraw({
|
|
345
|
+
inquiry: create(
|
|
346
|
+
{ from: g, to: g4 },
|
|
347
|
+
{ id: "7360fa66-83d2-4f6a-b489-5db46f6fd670" }
|
|
348
|
+
),
|
|
349
|
+
});
|
|
350
|
+
|
|
274
351
|
// addressed
|
|
275
352
|
confirm({
|
|
276
353
|
inquiry: answer({
|
|
@@ -340,4 +417,6 @@ export default function (server, groups) {
|
|
|
340
417
|
status: "inquiry-answer-status-positive",
|
|
341
418
|
}),
|
|
342
419
|
});
|
|
420
|
+
|
|
421
|
+
return distributionCase;
|
|
343
422
|
}
|
|
@@ -45,7 +45,7 @@ export default Factory.extend({
|
|
|
45
45
|
if (answer.value === undefined) {
|
|
46
46
|
answer.update({
|
|
47
47
|
value: [
|
|
48
|
-
faker.
|
|
48
|
+
faker.helpers.arrayElement(answer.question.options.models).slug,
|
|
49
49
|
],
|
|
50
50
|
});
|
|
51
51
|
}
|
|
@@ -54,18 +54,23 @@ export default Factory.extend({
|
|
|
54
54
|
|
|
55
55
|
if (answer.value === undefined) {
|
|
56
56
|
answer.update({
|
|
57
|
-
value: faker.
|
|
57
|
+
value: faker.helpers.arrayElement(answer.question.options.models)
|
|
58
|
+
.slug,
|
|
58
59
|
});
|
|
59
60
|
}
|
|
60
|
-
} else if (answer.question.type === "
|
|
61
|
-
answer.update({ type: "
|
|
61
|
+
} else if (answer.question.type === "FILES") {
|
|
62
|
+
answer.update({ type: "FILES" });
|
|
62
63
|
|
|
63
64
|
if (answer.value === undefined) {
|
|
64
65
|
answer.update({
|
|
65
|
-
value:
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
value: [
|
|
67
|
+
{
|
|
68
|
+
id: faker.datatype.uuid(),
|
|
69
|
+
name: faker.datatype.string(),
|
|
70
|
+
uploadUrl: faker.internet.url(),
|
|
71
|
+
downloadUrl: faker.internet.url(),
|
|
72
|
+
},
|
|
73
|
+
],
|
|
69
74
|
});
|
|
70
75
|
}
|
|
71
76
|
} else if (answer.question.type === "DATE") {
|
|
@@ -3,7 +3,7 @@ import { Factory } from "miragejs";
|
|
|
3
3
|
|
|
4
4
|
export default Factory.extend({
|
|
5
5
|
id: () => faker.datatype.uuid(),
|
|
6
|
-
|
|
6
|
+
name: () => faker.datatype.string(),
|
|
7
7
|
modifiedAt: () => faker.date.past(),
|
|
8
8
|
createdByUser: () => faker.datatype.uuid(),
|
|
9
9
|
uploadUrl: () => faker.internet.url(),
|
|
@@ -9,5 +9,10 @@ export default Factory.extend({
|
|
|
9
9
|
slug: (i) => `form-${i + 1}`,
|
|
10
10
|
description: () => faker.lorem.paragraph(),
|
|
11
11
|
isArchived: false,
|
|
12
|
+
isPublished: true,
|
|
12
13
|
meta: () => ({}),
|
|
14
|
+
createdByUser: () => faker.random.numeric(10),
|
|
15
|
+
createdByGroup: () => faker.random.numeric(10),
|
|
16
|
+
modifiedByUser: () => faker.random.numeric(10),
|
|
17
|
+
modifiedByGroup: () => faker.random.numeric(10),
|
|
13
18
|
});
|
|
@@ -9,11 +9,12 @@ export default Factory.extend({
|
|
|
9
9
|
createdByUser: () => faker.datatype.uuid(),
|
|
10
10
|
createdAt: () => faker.date.past(),
|
|
11
11
|
deadline: () => faker.date.future(),
|
|
12
|
-
status: () => faker.
|
|
12
|
+
status: () => faker.helpers.arrayElement(STATUS),
|
|
13
13
|
addressedGroups: () => ["group1", "group2"],
|
|
14
14
|
closedAt() {
|
|
15
15
|
return STATUS.filter((s) => s !== "READY").includes(this.status)
|
|
16
16
|
? faker.date.past()
|
|
17
17
|
: null;
|
|
18
18
|
},
|
|
19
|
+
isRedoable: () => false,
|
|
19
20
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@projectcaluma/ember-testing",
|
|
3
|
-
"version": "11.0.0-beta.
|
|
3
|
+
"version": "11.0.0-beta.31",
|
|
4
4
|
"description": "Ember addon for testing with Caluma addons.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon"
|
|
@@ -9,55 +9,54 @@
|
|
|
9
9
|
"homepage": "https://docs.caluma.io/ember-caluma",
|
|
10
10
|
"repository": "github:projectcaluma/ember-caluma",
|
|
11
11
|
"scripts": {
|
|
12
|
-
"test": "npm-run-all test
|
|
12
|
+
"test": "npm-run-all --print-name \"lint\" \"test:*\"",
|
|
13
13
|
"test:ember": "ember test",
|
|
14
14
|
"test:ember-compatibility": "ember try:each"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@
|
|
17
|
+
"@ember/string": "^3.0.0",
|
|
18
|
+
"@faker-js/faker": "^7.6.0",
|
|
18
19
|
"broccoli-funnel": "^3.0.8",
|
|
19
20
|
"broccoli-merge-trees": "^4.2.0",
|
|
20
|
-
"ember-apollo-client": "
|
|
21
|
-
"ember-auto-import": "^2.4.
|
|
21
|
+
"ember-apollo-client": "~4.0.2",
|
|
22
|
+
"ember-auto-import": "^2.4.3",
|
|
22
23
|
"ember-cli-babel": "^7.26.11",
|
|
23
|
-
"ember-cli-htmlbars": "^6.
|
|
24
|
-
"ember-cli-mirage": "^
|
|
25
|
-
"ember-fetch": "^8.1.
|
|
24
|
+
"ember-cli-htmlbars": "^6.1.1",
|
|
25
|
+
"ember-cli-mirage": "^3.0.0-alpha.3",
|
|
26
|
+
"ember-fetch": "^8.1.2",
|
|
26
27
|
"ember-inflector": "^4.0.2",
|
|
27
28
|
"graphql": "^15.8.0",
|
|
28
29
|
"graphql-iso-date": "^3.6.1",
|
|
29
30
|
"graphql-tools": "^4.0.8",
|
|
30
|
-
"luxon": "^
|
|
31
|
-
"miragejs": "^0.1.
|
|
31
|
+
"luxon": "^3.0.4",
|
|
32
|
+
"miragejs": "^0.1.45"
|
|
32
33
|
},
|
|
33
34
|
"devDependencies": {
|
|
34
35
|
"@ember/optional-features": "2.0.0",
|
|
35
|
-
"@ember/test-helpers": "2.
|
|
36
|
-
"@embroider/test-setup": "1.
|
|
36
|
+
"@ember/test-helpers": "2.7.0",
|
|
37
|
+
"@embroider/test-setup": "1.8.3",
|
|
37
38
|
"broccoli-asset-rev": "3.0.0",
|
|
38
|
-
"ember-cli": "
|
|
39
|
+
"ember-cli": "4.8.0",
|
|
39
40
|
"ember-cli-code-coverage": "1.0.3",
|
|
40
|
-
"ember-cli-dependency-checker": "3.
|
|
41
|
+
"ember-cli-dependency-checker": "3.3.1",
|
|
41
42
|
"ember-cli-inject-live-reload": "2.1.0",
|
|
42
43
|
"ember-cli-sri": "2.1.1",
|
|
43
44
|
"ember-cli-terser": "4.0.2",
|
|
44
45
|
"ember-disable-prototype-extensions": "1.1.3",
|
|
45
|
-
"ember-export-application-global": "2.0.1",
|
|
46
46
|
"ember-load-initializers": "2.1.2",
|
|
47
|
-
"ember-
|
|
48
|
-
"ember-qunit": "5.1.5",
|
|
47
|
+
"ember-qunit": "6.0.0",
|
|
49
48
|
"ember-resolver": "8.0.3",
|
|
50
|
-
"ember-source": "
|
|
49
|
+
"ember-source": "4.8.0",
|
|
51
50
|
"ember-source-channel-url": "3.0.0",
|
|
52
51
|
"ember-try": "2.0.0",
|
|
53
52
|
"graphql-tag": "2.12.6",
|
|
54
53
|
"loader.js": "4.7.0",
|
|
55
|
-
"qunit": "2.
|
|
54
|
+
"qunit": "2.19.2",
|
|
56
55
|
"qunit-dom": "2.0.0",
|
|
57
|
-
"webpack": "5.
|
|
56
|
+
"webpack": "5.74.0"
|
|
58
57
|
},
|
|
59
58
|
"engines": {
|
|
60
|
-
"node": "
|
|
59
|
+
"node": "14.* || 16.* || >= 18"
|
|
61
60
|
},
|
|
62
61
|
"ember": {
|
|
63
62
|
"edition": "octane"
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { classify } from "@ember/string";
|
|
2
|
-
import { singularize } from "ember-inflector";
|
|
3
|
-
import { graphql } from "graphql";
|
|
4
|
-
import {
|
|
5
|
-
GraphQLDate as Date,
|
|
6
|
-
GraphQLDateTime as DateTime,
|
|
7
|
-
} from "graphql-iso-date";
|
|
8
|
-
import { addMockFunctionsToSchema, makeExecutableSchema } from "graphql-tools";
|
|
9
|
-
|
|
10
|
-
import { Mock } from "@projectcaluma/ember-testing/mirage-graphql";
|
|
11
|
-
import typeDefs from "@projectcaluma/ember-testing/mirage-graphql/schema.graphql";
|
|
12
|
-
|
|
13
|
-
export default function (server) {
|
|
14
|
-
return function ({ db }, request) {
|
|
15
|
-
const mocks = db._collections.reduce((m, { name }) => {
|
|
16
|
-
const cls = classify(singularize(name));
|
|
17
|
-
const mock = new Mock(cls, server);
|
|
18
|
-
|
|
19
|
-
return { ...m, ...mock.getHandlers() };
|
|
20
|
-
}, {});
|
|
21
|
-
|
|
22
|
-
const schema = makeExecutableSchema({
|
|
23
|
-
typeDefs,
|
|
24
|
-
resolvers: {
|
|
25
|
-
Date,
|
|
26
|
-
DateTime,
|
|
27
|
-
GenericScalar: {
|
|
28
|
-
serialize(value) {
|
|
29
|
-
return typeof value === "string" ? JSON.parse(value) : value;
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
resolverValidationOptions: { requireResolversForResolveType: false },
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
const { query, variables } = JSON.parse(request.requestBody);
|
|
37
|
-
|
|
38
|
-
addMockFunctionsToSchema({
|
|
39
|
-
schema,
|
|
40
|
-
mocks: {
|
|
41
|
-
...mocks,
|
|
42
|
-
JSONString: () => JSON.stringify({}),
|
|
43
|
-
GenericScalar: () => ({}),
|
|
44
|
-
Node: (_, { id }) => ({ __typename: atob(id).split(":")[0] }),
|
|
45
|
-
SelectedOption: ({ value }) => {
|
|
46
|
-
const option = server.schema.options.findBy({ slug: value });
|
|
47
|
-
|
|
48
|
-
return {
|
|
49
|
-
slug: value,
|
|
50
|
-
label: option.label,
|
|
51
|
-
__typename: "SelectedOption",
|
|
52
|
-
};
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
preserveResolvers: false,
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
return graphql(schema, query, null, null, variables);
|
|
59
|
-
};
|
|
60
|
-
}
|