graphql-http 1.10.0 → 1.12.0

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/README.md CHANGED
@@ -141,6 +141,21 @@ fastify.listen({ port: 4000 });
141
141
  console.log('Listening to port 4000');
142
142
  ```
143
143
 
144
+ ##### With [`Koa`](https://koajs.com/)
145
+
146
+ ```js
147
+ import Koa from 'koa'; // yarn add koa
148
+ import mount from 'koa-mount'; // yarn add koa-mount
149
+ import { createHandler } from 'graphql-http/lib/use/koa';
150
+ import { schema } from './previous-step';
151
+
152
+ const app = new Koa();
153
+ app.use(mount('/graphql', createHandler({ schema })));
154
+
155
+ app.listen({ port: 4000 });
156
+ console.log('Listening to port 4000');
157
+ ```
158
+
144
159
  ##### With [`Deno`](https://deno.land/)
145
160
 
146
161
  ```ts
@@ -732,9 +747,12 @@ If you want a feature-full server with bleeding edge technologies, you're recomm
732
747
  | Name | Audit |
733
748
  | ------------------------------------------------------------------ | -------------------------------------------------------- |
734
749
  | [graphql-yoga](https://www.the-guild.dev/graphql/yoga-server) | [✅ Compliant](/implementations/graphql-yoga/README.md) |
750
+ | [graphql-helix](https://www.graphql-helix.com/) | [✅ Compliant](/implementations/graphql-helix/README.md) |
735
751
  | [hotchocolate](https://chillicream.com/docs/hotchocolate) | [✅ Compliant](/implementations/hotchocolate/README.md) |
752
+ | [pioneer](https://pioneer.dexclaimation.com/) | [✅ Compliant](/implementations/pioneer/README.md) |
736
753
  | [postgraphile](https://www.graphile.org/postgraphile/) | [✅ Compliant](/implementations/postgraphile/README.md) |
737
754
  | [apollo-server](https://www.apollographql.com/docs/apollo-server/) | [✅ Compliant](/implementations/apollo-server/README.md) |
755
+ | [deno](https://deno.com/blog/build-a-graphql-server-with-deno) | [✅ Compliant](/implementations/deno/README.md) |
738
756
 
739
757
  ## [Documentation](docs/)
740
758
 
@@ -49,6 +49,7 @@ export interface AuditFail {
49
49
  name: AuditName;
50
50
  status: 'warn' | 'error';
51
51
  reason: string;
52
+ response: Response;
52
53
  }
53
54
  /**
54
55
  * Result of the performed audit. See `AuditOk` and `AuditFail` for more information.
@@ -49,6 +49,7 @@ export interface AuditFail {
49
49
  name: AuditName;
50
50
  status: 'warn' | 'error';
51
51
  reason: string;
52
+ response: Response;
52
53
  }
53
54
  /**
54
55
  * Result of the performed audit. See `AuditOk` and `AuditFail` for more information.
@@ -27,8 +27,10 @@ function serverAudits(opts) {
27
27
  },
28
28
  body: JSON.stringify({ query: '{ __typename }' }),
29
29
  });
30
- (0, utils_1.assert)('Status code', res.status).toBe(200);
31
- (0, utils_1.assert)('Content-Type header', res.headers.get('content-type')).toContain('application/graphql-response+json');
30
+ (0, utils_1.ressert)(res).status.toBe(200);
31
+ (0, utils_1.ressert)(res)
32
+ .header('content-type')
33
+ .toContain('application/graphql-response+json');
32
34
  }),
33
35
  (0, utils_1.audit)('MUST accept application/json and match the content-type', async () => {
34
36
  const res = await fetchFn(await getUrl(opts.url), {
@@ -39,8 +41,8 @@ function serverAudits(opts) {
39
41
  },
40
42
  body: JSON.stringify({ query: '{ __typename }' }),
41
43
  });
42
- (0, utils_1.assert)('Status code', res.status).toBe(200);
43
- (0, utils_1.assert)('Content-Type header', res.headers.get('content-type')).toContain('application/json');
44
+ (0, utils_1.ressert)(res).status.toBe(200);
45
+ (0, utils_1.ressert)(res).header('content-type').toContain('application/json');
44
46
  }),
45
47
  (0, utils_1.audit)('SHOULD accept */* and use application/json for the content-type', async () => {
46
48
  const res = await fetchFn(await getUrl(opts.url), {
@@ -51,15 +53,15 @@ function serverAudits(opts) {
51
53
  },
52
54
  body: JSON.stringify({ query: '{ __typename }' }),
53
55
  });
54
- (0, utils_1.assert)('Status code', res.status).toBe(200);
55
- (0, utils_1.assert)('Content-Type header', res.headers.get('content-type')).toContain('application/json');
56
+ (0, utils_1.ressert)(res).status.toBe(200);
57
+ (0, utils_1.ressert)(res).header('content-type').toContain('application/json');
56
58
  }),
57
59
  (0, utils_1.audit)('SHOULD assume application/json content-type when accept is missing', async () => {
58
60
  const url = new URL(await getUrl(opts.url));
59
61
  url.searchParams.set('query', '{ __typename }');
60
62
  const res = await fetchFn(url.toString());
61
- (0, utils_1.assert)('Status code', res.status).toBe(200);
62
- (0, utils_1.assert)('Content-Type header', res.headers.get('content-type')).toContain('application/json');
63
+ (0, utils_1.ressert)(res).status.toBe(200);
64
+ (0, utils_1.ressert)(res).header('content-type').toContain('application/json');
63
65
  }),
64
66
  (0, utils_1.audit)('MUST use utf-8 encoding when responding', async () => {
65
67
  const res = await fetchFn(await getUrl(opts.url), {
@@ -69,28 +71,16 @@ function serverAudits(opts) {
69
71
  },
70
72
  body: JSON.stringify({ query: '{ __typename }' }),
71
73
  });
72
- (0, utils_1.assert)('Status code', res.status).toBe(200);
73
- // has charset set to utf-8
74
- try {
75
- (0, utils_1.assert)('Content-Type header', res.headers.get('content-type')).toContain('charset=utf-8');
76
- return;
77
- }
78
- catch (_a) {
79
- // noop, continue
80
- }
81
- // has no charset specified
82
- (0, utils_1.assert)('Content-Type header', res.headers.get('content-type')).notToContain('charset');
83
- // and the content is utf-8 encoded
74
+ (0, utils_1.ressert)(res).status.toBe(200);
84
75
  try {
85
76
  const decoder = new TextDecoder('utf-8');
86
- const decoded = decoder.decode(await res.arrayBuffer());
87
- (0, utils_1.assert)('UTF-8 decoded body', decoded).toBe('{"data":{"__typename":"Query"}}');
77
+ decoder.decode(await res.arrayBuffer());
88
78
  }
89
- catch (_b) {
90
- throw 'Body is not UTF-8 encoded';
79
+ catch (_a) {
80
+ throw new utils_1.AuditError(res, 'Response body is not UTF-8 encoded');
91
81
  }
92
82
  }),
93
- (0, utils_1.audit)('MUST accept utf-8 encoding', async () => {
83
+ (0, utils_1.audit)('MUST accept utf-8 encoded request', async () => {
94
84
  const res = await fetchFn(await getUrl(opts.url), {
95
85
  method: 'POST',
96
86
  headers: {
@@ -98,10 +88,9 @@ function serverAudits(opts) {
98
88
  },
99
89
  body: JSON.stringify({ query: '{ __typename }' }),
100
90
  });
101
- (0, utils_1.assert)('Status code', res.status).toBe(200);
102
- (0, utils_1.assert)('Content-Type header', res.headers.get('content-type')).toContain('utf-8');
91
+ (0, utils_1.ressert)(res).status.toBe(200);
103
92
  }),
104
- (0, utils_1.audit)('MUST assume utf-8 if encoding is unspecified', async () => {
93
+ (0, utils_1.audit)('MUST assume utf-8 in request if encoding is unspecified', async () => {
105
94
  const res = await fetchFn(await getUrl(opts.url), {
106
95
  method: 'POST',
107
96
  headers: {
@@ -109,8 +98,7 @@ function serverAudits(opts) {
109
98
  },
110
99
  body: JSON.stringify({ query: '{ __typename }' }),
111
100
  });
112
- (0, utils_1.assert)('Status code', res.status).toBe(200);
113
- (0, utils_1.assert)('Content-Type header', res.headers.get('content-type')).toContain('utf-8');
101
+ (0, utils_1.ressert)(res).status.toBe(200);
114
102
  }),
115
103
  // Request
116
104
  (0, utils_1.audit)('MUST accept POST requests', async () => {
@@ -119,13 +107,13 @@ function serverAudits(opts) {
119
107
  headers: { 'content-type': 'application/json' },
120
108
  body: JSON.stringify({ query: '{ __typename }' }),
121
109
  });
122
- (0, utils_1.assert)('Status code', res.status).toBe(200);
110
+ (0, utils_1.ressert)(res).status.toBe(200);
123
111
  }),
124
112
  (0, utils_1.audit)('MAY accept application/x-www-form-urlencoded formatted GET requests', async () => {
125
113
  const url = new URL(await getUrl(opts.url));
126
114
  url.searchParams.set('query', '{ __typename }');
127
115
  const res = await fetchFn(url.toString());
128
- (0, utils_1.assert)('Status code', res.status).toBe(200);
116
+ (0, utils_1.ressert)(res).status.toBe(200);
129
117
  }),
130
118
  // Request GET
131
119
  // TODO: this is a MUST if the server supports GET requests
@@ -137,14 +125,14 @@ function serverAudits(opts) {
137
125
  accept: 'application/graphql-response+json',
138
126
  },
139
127
  });
140
- (0, utils_1.assert)('Status code', res.status).toBeBetween(400, 499);
128
+ (0, utils_1.ressert)(res).status.toBeBetween(400, 499);
141
129
  }),
142
130
  // Request POST
143
131
  (0, utils_1.audit)('SHOULD respond with 4xx status code if content-type is not supplied on POST requests', async () => {
144
132
  const res = await fetchFn(await getUrl(opts.url), {
145
133
  method: 'POST',
146
134
  });
147
- (0, utils_1.assert)('Status code', res.status).toBeBetween(400, 499);
135
+ (0, utils_1.ressert)(res).status.toBeBetween(400, 499);
148
136
  }),
149
137
  (0, utils_1.audit)('MUST accept application/json POST requests', async () => {
150
138
  const res = await fetchFn(await getUrl(opts.url), {
@@ -152,7 +140,7 @@ function serverAudits(opts) {
152
140
  headers: { 'content-type': 'application/json' },
153
141
  body: JSON.stringify({ query: '{ __typename }' }),
154
142
  });
155
- (0, utils_1.assert)('Status code', res.status).toBe(200);
143
+ (0, utils_1.ressert)(res).status.toBe(200);
156
144
  }),
157
145
  (0, utils_1.audit)('MUST require a request body on POST', async () => {
158
146
  var _a;
@@ -161,10 +149,10 @@ function serverAudits(opts) {
161
149
  headers: { 'content-type': 'application/json' },
162
150
  });
163
151
  if ((_a = res.headers.get('content-type')) === null || _a === void 0 ? void 0 : _a.includes('application/json')) {
164
- (0, utils_1.assert)('Execution result', await (0, utils_1.assertBodyAsExecutionResult)(res)).toHaveProperty('errors');
152
+ await (0, utils_1.ressert)(res).bodyAsExecutionResult.toHaveProperty('errors');
165
153
  }
166
154
  else {
167
- (0, utils_1.assert)('Status code', res.status).toBe(400);
155
+ (0, utils_1.ressert)(res).status.toBe(400);
168
156
  }
169
157
  }),
170
158
  // Request Parameters
@@ -179,7 +167,7 @@ function serverAudits(opts) {
179
167
  },
180
168
  body: JSON.stringify({ notquery: '{ __typename }' }),
181
169
  });
182
- (0, utils_1.assert)('Status code', res.status).toBe(400);
170
+ (0, utils_1.ressert)(res).status.toBe(400);
183
171
  }),
184
172
  (0, utils_1.audit)('SHOULD use 200 status code with errors field on missing {query} parameter when accepting application/json', async () => {
185
173
  const res = await fetchFn(await getUrl(opts.url), {
@@ -190,8 +178,8 @@ function serverAudits(opts) {
190
178
  },
191
179
  body: JSON.stringify({ notquery: '{ __typename }' }),
192
180
  });
193
- (0, utils_1.assert)('Status code', res.status).toBe(200);
194
- (0, utils_1.assert)('Execution result', await (0, utils_1.assertBodyAsExecutionResult)(res)).toHaveProperty('errors');
181
+ (0, utils_1.ressert)(res).status.toBe(200);
182
+ await (0, utils_1.ressert)(res).bodyAsExecutionResult.toHaveProperty('errors');
195
183
  }),
196
184
  ...[{ obj: 'ect' }, 0, false, ['array']].map((invalid) => (0, utils_1.audit)(
197
185
  // TODO: convert to MUST after watershed
@@ -206,7 +194,7 @@ function serverAudits(opts) {
206
194
  query: invalid,
207
195
  }),
208
196
  });
209
- (0, utils_1.assert)('Status code', res.status).toBe(400);
197
+ (0, utils_1.ressert)(res).status.toBe(400);
210
198
  })),
211
199
  ...[{ obj: 'ect' }, 0, false, ['array']].map((invalid) => (0, utils_1.audit)(`SHOULD use 200 status code with errors field on ${(0, utils_1.extendedTypeof)(invalid)} {query} parameter when accepting application/json`, async () => {
212
200
  const res = await fetchFn(await getUrl(opts.url), {
@@ -219,8 +207,8 @@ function serverAudits(opts) {
219
207
  query: invalid,
220
208
  }),
221
209
  });
222
- (0, utils_1.assert)('Status code', res.status).toBe(200);
223
- (0, utils_1.assert)('Execution result', await (0, utils_1.assertBodyAsExecutionResult)(res)).toHaveProperty('errors');
210
+ (0, utils_1.ressert)(res).status.toBe(200);
211
+ await (0, utils_1.ressert)(res).bodyAsExecutionResult.toHaveProperty('errors');
224
212
  })),
225
213
  (0, utils_1.audit)(
226
214
  // TODO: convert to MUST after watershed
@@ -235,7 +223,7 @@ function serverAudits(opts) {
235
223
  query: '{ __typename }',
236
224
  }),
237
225
  });
238
- (0, utils_1.assert)('Status code', res.status).toBe(200);
226
+ (0, utils_1.ressert)(res).status.toBe(200);
239
227
  }),
240
228
  (0, utils_1.audit)('MUST allow string {query} parameter when accepting application/json', async () => {
241
229
  const res = await fetchFn(await getUrl(opts.url), {
@@ -248,8 +236,8 @@ function serverAudits(opts) {
248
236
  query: '{ __typename }',
249
237
  }),
250
238
  });
251
- (0, utils_1.assert)('Status code', res.status).toBe(200);
252
- (0, utils_1.assert)('Execution result', await (0, utils_1.assertBodyAsExecutionResult)(res)).notToHaveProperty('errors');
239
+ (0, utils_1.ressert)(res).status.toBe(200);
240
+ await (0, utils_1.ressert)(res).bodyAsExecutionResult.notToHaveProperty('errors');
253
241
  }),
254
242
  ...[{ obj: 'ect' }, 0, false, ['array']].map((invalid) => (0, utils_1.audit)(
255
243
  // TODO: convert to MUST after watershed
@@ -265,7 +253,7 @@ function serverAudits(opts) {
265
253
  query: '{ __typename }',
266
254
  }),
267
255
  });
268
- (0, utils_1.assert)('Status code', res.status).toBe(400);
256
+ (0, utils_1.ressert)(res).status.toBe(400);
269
257
  })),
270
258
  ...[{ obj: 'ect' }, 0, false, ['array']].map((invalid) => (0, utils_1.audit)(`SHOULD use 200 status code with errors field on ${(0, utils_1.extendedTypeof)(invalid)} {operationName} parameter when accepting application/json`, async () => {
271
259
  const res = await fetchFn(await getUrl(opts.url), {
@@ -279,8 +267,8 @@ function serverAudits(opts) {
279
267
  query: '{ __typename }',
280
268
  }),
281
269
  });
282
- (0, utils_1.assert)('Status code', res.status).toBe(200);
283
- (0, utils_1.assert)('Execution result', await (0, utils_1.assertBodyAsExecutionResult)(res)).toHaveProperty('errors');
270
+ (0, utils_1.ressert)(res).status.toBe(200);
271
+ await (0, utils_1.ressert)(res).bodyAsExecutionResult.toHaveProperty('errors');
284
272
  })),
285
273
  (0, utils_1.audit)(
286
274
  // TODO: convert to MUST after watershed
@@ -296,7 +284,7 @@ function serverAudits(opts) {
296
284
  query: 'query Query { __typename }',
297
285
  }),
298
286
  });
299
- (0, utils_1.assert)('Status code', res.status).toBe(200);
287
+ (0, utils_1.ressert)(res).status.toBe(200);
300
288
  }),
301
289
  (0, utils_1.audit)('MUST allow string {operationName} parameter when accepting application/json', async () => {
302
290
  const res = await fetchFn(await getUrl(opts.url), {
@@ -310,8 +298,8 @@ function serverAudits(opts) {
310
298
  query: 'query Query { __typename }',
311
299
  }),
312
300
  });
313
- (0, utils_1.assert)('Status code', res.status).toBe(200);
314
- (0, utils_1.assert)('Execution result', await (0, utils_1.assertBodyAsExecutionResult)(res)).notToHaveProperty('errors');
301
+ (0, utils_1.ressert)(res).status.toBe(200);
302
+ await (0, utils_1.ressert)(res).bodyAsExecutionResult.notToHaveProperty('errors');
315
303
  }),
316
304
  ...['variables', 'operationName', 'extensions'].flatMap((parameter) => [
317
305
  (0, utils_1.audit)(
@@ -328,8 +316,8 @@ function serverAudits(opts) {
328
316
  [parameter]: null,
329
317
  }),
330
318
  });
331
- (0, utils_1.assert)('Status code', res.status).toBe(200);
332
- (0, utils_1.assert)('Execution result', await (0, utils_1.assertBodyAsExecutionResult)(res)).notToHaveProperty('errors');
319
+ (0, utils_1.ressert)(res).status.toBe(200);
320
+ await (0, utils_1.ressert)(res).bodyAsExecutionResult.notToHaveProperty('errors');
333
321
  }),
334
322
  (0, utils_1.audit)(`MUST allow null {${parameter}} parameter when accepting application/json`, async () => {
335
323
  const res = await fetchFn(await getUrl(opts.url), {
@@ -343,8 +331,8 @@ function serverAudits(opts) {
343
331
  [parameter]: null,
344
332
  }),
345
333
  });
346
- (0, utils_1.assert)('Status code', res.status).toBe(200);
347
- (0, utils_1.assert)('Execution result', await (0, utils_1.assertBodyAsExecutionResult)(res)).notToHaveProperty('errors');
334
+ (0, utils_1.ressert)(res).status.toBe(200);
335
+ await (0, utils_1.ressert)(res).bodyAsExecutionResult.notToHaveProperty('errors');
348
336
  }),
349
337
  ]),
350
338
  ...['string', 0, false, ['array']].map((invalid) => (0, utils_1.audit)(
@@ -361,7 +349,7 @@ function serverAudits(opts) {
361
349
  variables: invalid,
362
350
  }),
363
351
  });
364
- (0, utils_1.assert)('Status code', res.status).toBe(400);
352
+ (0, utils_1.ressert)(res).status.toBe(400);
365
353
  })),
366
354
  ...['string', 0, false, ['array']].map((invalid) => (0, utils_1.audit)(`SHOULD use 200 status code with errors field on ${(0, utils_1.extendedTypeof)(invalid)} {variables} parameter when accepting application/json`, async () => {
367
355
  const res = await fetchFn(await getUrl(opts.url), {
@@ -375,8 +363,8 @@ function serverAudits(opts) {
375
363
  variables: invalid,
376
364
  }),
377
365
  });
378
- (0, utils_1.assert)('Status code', res.status).toBe(200);
379
- (0, utils_1.assert)('Execution result', await (0, utils_1.assertBodyAsExecutionResult)(res)).toHaveProperty('errors');
366
+ (0, utils_1.ressert)(res).status.toBe(200);
367
+ await (0, utils_1.ressert)(res).bodyAsExecutionResult.toHaveProperty('errors');
380
368
  })),
381
369
  (0, utils_1.audit)(
382
370
  // TODO: convert to MUST after watershed
@@ -392,7 +380,7 @@ function serverAudits(opts) {
392
380
  variables: { name: 'sometype' },
393
381
  }),
394
382
  });
395
- (0, utils_1.assert)('Status code', res.status).toBe(200);
383
+ (0, utils_1.ressert)(res).status.toBe(200);
396
384
  }),
397
385
  (0, utils_1.audit)('MUST allow map {variables} parameter when accepting application/json', async () => {
398
386
  const res = await fetchFn(await getUrl(opts.url), {
@@ -406,8 +394,8 @@ function serverAudits(opts) {
406
394
  variables: { name: 'sometype' },
407
395
  }),
408
396
  });
409
- (0, utils_1.assert)('Status code', res.status).toBe(200);
410
- (0, utils_1.assert)('Execution result', await (0, utils_1.assertBodyAsExecutionResult)(res)).notToHaveProperty('errors');
397
+ (0, utils_1.ressert)(res).status.toBe(200);
398
+ await (0, utils_1.ressert)(res).bodyAsExecutionResult.notToHaveProperty('errors');
411
399
  }),
412
400
  (0, utils_1.audit)('MAY allow URL-encoded JSON string {variables} parameter in GETs when accepting application/graphql-response+json', async () => {
413
401
  const url = new URL(await getUrl(opts.url));
@@ -419,7 +407,7 @@ function serverAudits(opts) {
419
407
  accept: 'application/graphql-response+json',
420
408
  },
421
409
  });
422
- (0, utils_1.assert)('Status code', res.status).toBe(200);
410
+ (0, utils_1.ressert)(res).status.toBe(200);
423
411
  }),
424
412
  (0, utils_1.audit)('MAY allow URL-encoded JSON string {variables} parameter in GETs when accepting application/json', async () => {
425
413
  const url = new URL(await getUrl(opts.url));
@@ -431,8 +419,8 @@ function serverAudits(opts) {
431
419
  accept: 'application/json',
432
420
  },
433
421
  });
434
- (0, utils_1.assert)('Status code', res.status).toBe(200);
435
- (0, utils_1.assert)('Execution result', await (0, utils_1.assertBodyAsExecutionResult)(res)).notToHaveProperty('errors');
422
+ (0, utils_1.ressert)(res).status.toBe(200);
423
+ await (0, utils_1.ressert)(res).bodyAsExecutionResult.notToHaveProperty('errors');
436
424
  }),
437
425
  ...['string', 0, false, ['array']].map((invalid) => (0, utils_1.audit)(
438
426
  // TODO: convert to MUST after watershed
@@ -448,7 +436,7 @@ function serverAudits(opts) {
448
436
  extensions: invalid,
449
437
  }),
450
438
  });
451
- (0, utils_1.assert)('Status code', res.status).toBe(400);
439
+ (0, utils_1.ressert)(res).status.toBe(400);
452
440
  })),
453
441
  ...['string', 0, false, ['array']].map((invalid) => (0, utils_1.audit)(`SHOULD use 200 status code with errors field on ${(0, utils_1.extendedTypeof)(invalid)} {extensions} parameter when accepting application/json`, async () => {
454
442
  const res = await fetchFn(await getUrl(opts.url), {
@@ -462,8 +450,8 @@ function serverAudits(opts) {
462
450
  extensions: invalid,
463
451
  }),
464
452
  });
465
- (0, utils_1.assert)('Status code', res.status).toBe(200);
466
- (0, utils_1.assert)('Execution result', await (0, utils_1.assertBodyAsExecutionResult)(res)).toHaveProperty('errors');
453
+ (0, utils_1.ressert)(res).status.toBe(200);
454
+ await (0, utils_1.ressert)(res).bodyAsExecutionResult.toHaveProperty('errors');
467
455
  })),
468
456
  (0, utils_1.audit)(
469
457
  // TODO: convert to MUST after watershed
@@ -479,7 +467,7 @@ function serverAudits(opts) {
479
467
  extensions: { some: 'value' },
480
468
  }),
481
469
  });
482
- (0, utils_1.assert)('Status code', res.status).toBe(200);
470
+ (0, utils_1.ressert)(res).status.toBe(200);
483
471
  }),
484
472
  (0, utils_1.audit)('MUST allow map {extensions} parameter when accepting application/json', async () => {
485
473
  const res = await fetchFn(await getUrl(opts.url), {
@@ -493,8 +481,8 @@ function serverAudits(opts) {
493
481
  extensions: { some: 'value' },
494
482
  }),
495
483
  });
496
- (0, utils_1.assert)('Status code', res.status).toBe(200);
497
- (0, utils_1.assert)('Execution result', await (0, utils_1.assertBodyAsExecutionResult)(res)).notToHaveProperty('errors');
484
+ (0, utils_1.ressert)(res).status.toBe(200);
485
+ await (0, utils_1.ressert)(res).bodyAsExecutionResult.notToHaveProperty('errors');
498
486
  }),
499
487
  // TODO: audit('MUST accept a map for the {extensions} parameter'),
500
488
  // Response application/json
@@ -507,7 +495,7 @@ function serverAudits(opts) {
507
495
  },
508
496
  body: '{ "not a JSON',
509
497
  });
510
- (0, utils_1.assert)('Status code', res.status).toBe(200);
498
+ (0, utils_1.ressert)(res).status.toBe(200);
511
499
  }),
512
500
  (0, utils_1.audit)('SHOULD use 200 status code if parameters are invalid when accepting application/json', async () => {
513
501
  const res = await fetchFn(await getUrl(opts.url), {
@@ -520,7 +508,7 @@ function serverAudits(opts) {
520
508
  qeury: /* typo */ '{ __typename }',
521
509
  }),
522
510
  });
523
- (0, utils_1.assert)('Status code', res.status).toBe(200);
511
+ (0, utils_1.ressert)(res).status.toBe(200);
524
512
  }),
525
513
  (0, utils_1.audit)('SHOULD use 200 status code on document parsing failure when accepting application/json', async () => {
526
514
  const res = await fetchFn(await getUrl(opts.url), {
@@ -531,7 +519,7 @@ function serverAudits(opts) {
531
519
  },
532
520
  body: JSON.stringify({ query: '{' }),
533
521
  });
534
- (0, utils_1.assert)('Status code', res.status).toBe(200);
522
+ (0, utils_1.ressert)(res).status.toBe(200);
535
523
  }),
536
524
  (0, utils_1.audit)('SHOULD use 200 status code on document validation failure when accepting application/json', async () => {
537
525
  const res = await fetchFn(await getUrl(opts.url), {
@@ -544,7 +532,7 @@ function serverAudits(opts) {
544
532
  query: '{ 8f31403dfe404bccbb0e835f2629c6a7 }', // making sure the field doesnt exist
545
533
  }),
546
534
  });
547
- (0, utils_1.assert)('Status code', res.status).toBe(200);
535
+ (0, utils_1.ressert)(res).status.toBe(200);
548
536
  }),
549
537
  // Response application/graphql-response+json
550
538
  (0, utils_1.audit)(
@@ -558,7 +546,7 @@ function serverAudits(opts) {
558
546
  },
559
547
  body: '{ "not a JSON',
560
548
  });
561
- (0, utils_1.assert)('Status code', res.status).toBeBetween(400, 499);
549
+ (0, utils_1.ressert)(res).status.toBeBetween(400, 499);
562
550
  }),
563
551
  (0, utils_1.audit)('SHOULD use 400 status code on JSON parsing failure when accepting application/graphql-response+json', async () => {
564
552
  const res = await fetchFn(await getUrl(opts.url), {
@@ -569,7 +557,7 @@ function serverAudits(opts) {
569
557
  },
570
558
  body: '{ "not a JSON',
571
559
  });
572
- (0, utils_1.assert)('Status code', res.status).toBe(400);
560
+ (0, utils_1.ressert)(res).status.toBe(400);
573
561
  }),
574
562
  (0, utils_1.audit)('SHOULD not contain the data entry on JSON parsing failure when accepting application/graphql-response+json', async () => {
575
563
  const res = await fetchFn(await getUrl(opts.url), {
@@ -580,7 +568,7 @@ function serverAudits(opts) {
580
568
  },
581
569
  body: '{ "not a JSON',
582
570
  });
583
- (0, utils_1.assert)('Data entry', (await (0, utils_1.assertBodyAsExecutionResult)(res)).data).toBe(undefined);
571
+ await (0, utils_1.ressert)(res).bodyAsExecutionResult.data.toBe(undefined);
584
572
  }),
585
573
  (0, utils_1.audit)(
586
574
  // TODO: convert to MUST after watershed
@@ -595,7 +583,7 @@ function serverAudits(opts) {
595
583
  qeury /* typo */: '{ __typename }',
596
584
  }),
597
585
  });
598
- (0, utils_1.assert)('Status code', res.status).toBeBetween(400, 599);
586
+ (0, utils_1.ressert)(res).status.toBeBetween(400, 599);
599
587
  }),
600
588
  (0, utils_1.audit)('SHOULD use 400 status code if parameters are invalid when accepting application/graphql-response+json', async () => {
601
589
  const res = await fetchFn(await getUrl(opts.url), {
@@ -608,7 +596,7 @@ function serverAudits(opts) {
608
596
  qeury: /* typo */ '{ __typename }',
609
597
  }),
610
598
  });
611
- (0, utils_1.assert)('Status code', res.status).toBe(400);
599
+ (0, utils_1.ressert)(res).status.toBe(400);
612
600
  }),
613
601
  (0, utils_1.audit)('SHOULD not contain the data entry if parameters are invalid when accepting application/graphql-response+json', async () => {
614
602
  const res = await fetchFn(await getUrl(opts.url), {
@@ -621,7 +609,7 @@ function serverAudits(opts) {
621
609
  qeury: /* typo */ '{ __typename }',
622
610
  }),
623
611
  });
624
- (0, utils_1.assert)('Data entry', (await (0, utils_1.assertBodyAsExecutionResult)(res)).data).toBe(undefined);
612
+ await (0, utils_1.ressert)(res).bodyAsExecutionResult.data.toBe(undefined);
625
613
  }),
626
614
  (0, utils_1.audit)(
627
615
  // TODO: convert to MUST after watershed
@@ -636,7 +624,7 @@ function serverAudits(opts) {
636
624
  query: '{',
637
625
  }),
638
626
  });
639
- (0, utils_1.assert)('Status code', res.status).toBeBetween(400, 599);
627
+ (0, utils_1.ressert)(res).status.toBeBetween(400, 599);
640
628
  }),
641
629
  (0, utils_1.audit)('SHOULD use 400 status code on document parsing failure when accepting application/graphql-response+json', async () => {
642
630
  const res = await fetchFn(await getUrl(opts.url), {
@@ -649,7 +637,7 @@ function serverAudits(opts) {
649
637
  query: '{',
650
638
  }),
651
639
  });
652
- (0, utils_1.assert)('Status code', res.status).toBe(400);
640
+ (0, utils_1.ressert)(res).status.toBe(400);
653
641
  }),
654
642
  (0, utils_1.audit)('SHOULD not contain the data entry on document parsing failure when accepting application/graphql-response+json', async () => {
655
643
  const res = await fetchFn(await getUrl(opts.url), {
@@ -662,7 +650,7 @@ function serverAudits(opts) {
662
650
  query: '{',
663
651
  }),
664
652
  });
665
- (0, utils_1.assert)('Data entry', (await (0, utils_1.assertBodyAsExecutionResult)(res)).data).toBe(undefined);
653
+ await (0, utils_1.ressert)(res).bodyAsExecutionResult.data.toBe(undefined);
666
654
  }),
667
655
  (0, utils_1.audit)(
668
656
  // TODO: convert to MUST after watershed
@@ -677,7 +665,7 @@ function serverAudits(opts) {
677
665
  query: '{ 8f31403dfe404bccbb0e835f2629c6a7 }', // making sure the field doesnt exist
678
666
  }),
679
667
  });
680
- (0, utils_1.assert)('Status code', res.status).toBeBetween(400, 599);
668
+ (0, utils_1.ressert)(res).status.toBeBetween(400, 599);
681
669
  }),
682
670
  (0, utils_1.audit)('SHOULD use 400 status code on document validation failure when accepting application/graphql-response+json', async () => {
683
671
  const res = await fetchFn(await getUrl(opts.url), {
@@ -690,7 +678,7 @@ function serverAudits(opts) {
690
678
  query: '{ 8f31403dfe404bccbb0e835f2629c6a7 }', // making sure the field doesnt exist
691
679
  }),
692
680
  });
693
- (0, utils_1.assert)('Status code', res.status).toBe(400);
681
+ (0, utils_1.ressert)(res).status.toBe(400);
694
682
  }),
695
683
  (0, utils_1.audit)('SHOULD not contain the data entry on document validation failure when accepting application/graphql-response+json', async () => {
696
684
  const res = await fetchFn(await getUrl(opts.url), {
@@ -703,7 +691,7 @@ function serverAudits(opts) {
703
691
  query: '{ 8f31403dfe404bccbb0e835f2629c6a7 }', // making sure the field doesnt exist
704
692
  }),
705
693
  });
706
- (0, utils_1.assert)('Data entry', (await (0, utils_1.assertBodyAsExecutionResult)(res)).data).toBe(undefined);
694
+ await (0, utils_1.ressert)(res).bodyAsExecutionResult.data.toBe(undefined);
707
695
  }),
708
696
  // TODO: how to fail and have the data entry?
709
697
  // audit('MUST use 2xx status code if response contains the data entry and it is not null when accepting application/graphql-response+json'),