graphql-http 1.8.0 → 1.9.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 +0 -1
- package/lib/audits/server.d.mts +1 -1
- package/lib/audits/server.d.ts +1 -1
- package/lib/audits/server.js +37 -3
- package/lib/audits/server.mjs +37 -3
- package/package.json +1 -1
- package/umd/graphql-http.min.js.gz +0 -0
package/README.md
CHANGED
|
@@ -735,7 +735,6 @@ If you want a feature-full server with bleeding edge technologies, you're recomm
|
|
|
735
735
|
| [hotchocolate](https://chillicream.com/docs/hotchocolate) | [✅ Compliant](/implementations/hotchocolate/README.md) |
|
|
736
736
|
| [postgraphile](https://www.graphile.org/postgraphile/) | [✅ Compliant](/implementations/postgraphile/README.md) |
|
|
737
737
|
| [apollo-server](https://www.apollographql.com/docs/apollo-server/) | [✅ Compliant](/implementations/apollo-server/README.md) |
|
|
738
|
-
| [mercurius](https://mercurius.dev) | [✅ Compliant](/implementations/mercurius/README.md) |
|
|
739
738
|
|
|
740
739
|
## [Documentation](docs/)
|
|
741
740
|
|
package/lib/audits/server.d.mts
CHANGED
|
@@ -16,7 +16,7 @@ export interface ServerAuditOptions {
|
|
|
16
16
|
* A function can be also supplied, in this case -
|
|
17
17
|
* every audit will invoke the function to get the URL.
|
|
18
18
|
*/
|
|
19
|
-
url: string | (() => string | Promise<string>);
|
|
19
|
+
url: string | Promise<string> | (() => string | Promise<string>);
|
|
20
20
|
/**
|
|
21
21
|
* The Fetch function to use.
|
|
22
22
|
*
|
package/lib/audits/server.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export interface ServerAuditOptions {
|
|
|
16
16
|
* A function can be also supplied, in this case -
|
|
17
17
|
* every audit will invoke the function to get the URL.
|
|
18
18
|
*/
|
|
19
|
-
url: string | (() => string | Promise<string>);
|
|
19
|
+
url: string | Promise<string> | (() => string | Promise<string>);
|
|
20
20
|
/**
|
|
21
21
|
* The Fetch function to use.
|
|
22
22
|
*
|
package/lib/audits/server.js
CHANGED
|
@@ -313,6 +313,40 @@ function serverAudits(opts) {
|
|
|
313
313
|
(0, utils_1.assert)('Status code', res.status).toBe(200);
|
|
314
314
|
(0, utils_1.assert)('Execution result', await (0, utils_1.assertBodyAsExecutionResult)(res)).notToHaveProperty('errors');
|
|
315
315
|
}),
|
|
316
|
+
...['variables', 'operationName', 'extensions'].flatMap((parameter) => [
|
|
317
|
+
(0, utils_1.audit)(
|
|
318
|
+
// TODO: convert to MUST after watershed
|
|
319
|
+
`SHOULD allow null {${parameter}} parameter when accepting application/graphql-response+json`, async () => {
|
|
320
|
+
const res = await fetchFn(await getUrl(opts.url), {
|
|
321
|
+
method: 'POST',
|
|
322
|
+
headers: {
|
|
323
|
+
'content-type': 'application/json',
|
|
324
|
+
accept: 'application/graphql-response+json',
|
|
325
|
+
},
|
|
326
|
+
body: JSON.stringify({
|
|
327
|
+
query: '{ __typename }',
|
|
328
|
+
[parameter]: null,
|
|
329
|
+
}),
|
|
330
|
+
});
|
|
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');
|
|
333
|
+
}),
|
|
334
|
+
(0, utils_1.audit)(`MUST allow null {${parameter}} parameter when accepting application/json`, async () => {
|
|
335
|
+
const res = await fetchFn(await getUrl(opts.url), {
|
|
336
|
+
method: 'POST',
|
|
337
|
+
headers: {
|
|
338
|
+
'content-type': 'application/json',
|
|
339
|
+
accept: 'application/json',
|
|
340
|
+
},
|
|
341
|
+
body: JSON.stringify({
|
|
342
|
+
query: '{ __typename }',
|
|
343
|
+
[parameter]: null,
|
|
344
|
+
}),
|
|
345
|
+
});
|
|
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');
|
|
348
|
+
}),
|
|
349
|
+
]),
|
|
316
350
|
...['string', 0, false, ['array']].map((invalid) => (0, utils_1.audit)(
|
|
317
351
|
// TODO: convert to MUST after watershed
|
|
318
352
|
`SHOULD use 400 status code on ${(0, utils_1.extendedTypeof)(invalid)} {variables} parameter when accepting application/graphql-response+json`, async () => {
|
|
@@ -694,8 +728,8 @@ async function auditServer(opts) {
|
|
|
694
728
|
exports.auditServer = auditServer;
|
|
695
729
|
/** @private */
|
|
696
730
|
async function getUrl(url) {
|
|
697
|
-
if (typeof url === '
|
|
698
|
-
return url;
|
|
731
|
+
if (typeof url === 'function') {
|
|
732
|
+
return await url();
|
|
699
733
|
}
|
|
700
|
-
return
|
|
734
|
+
return url;
|
|
701
735
|
}
|
package/lib/audits/server.mjs
CHANGED
|
@@ -310,6 +310,40 @@ export function serverAudits(opts) {
|
|
|
310
310
|
assert('Status code', res.status).toBe(200);
|
|
311
311
|
assert('Execution result', await assertBodyAsExecutionResult(res)).notToHaveProperty('errors');
|
|
312
312
|
}),
|
|
313
|
+
...['variables', 'operationName', 'extensions'].flatMap((parameter) => [
|
|
314
|
+
audit(
|
|
315
|
+
// TODO: convert to MUST after watershed
|
|
316
|
+
`SHOULD allow null {${parameter}} parameter when accepting application/graphql-response+json`, async () => {
|
|
317
|
+
const res = await fetchFn(await getUrl(opts.url), {
|
|
318
|
+
method: 'POST',
|
|
319
|
+
headers: {
|
|
320
|
+
'content-type': 'application/json',
|
|
321
|
+
accept: 'application/graphql-response+json',
|
|
322
|
+
},
|
|
323
|
+
body: JSON.stringify({
|
|
324
|
+
query: '{ __typename }',
|
|
325
|
+
[parameter]: null,
|
|
326
|
+
}),
|
|
327
|
+
});
|
|
328
|
+
assert('Status code', res.status).toBe(200);
|
|
329
|
+
assert('Execution result', await assertBodyAsExecutionResult(res)).notToHaveProperty('errors');
|
|
330
|
+
}),
|
|
331
|
+
audit(`MUST allow null {${parameter}} parameter when accepting application/json`, async () => {
|
|
332
|
+
const res = await fetchFn(await getUrl(opts.url), {
|
|
333
|
+
method: 'POST',
|
|
334
|
+
headers: {
|
|
335
|
+
'content-type': 'application/json',
|
|
336
|
+
accept: 'application/json',
|
|
337
|
+
},
|
|
338
|
+
body: JSON.stringify({
|
|
339
|
+
query: '{ __typename }',
|
|
340
|
+
[parameter]: null,
|
|
341
|
+
}),
|
|
342
|
+
});
|
|
343
|
+
assert('Status code', res.status).toBe(200);
|
|
344
|
+
assert('Execution result', await assertBodyAsExecutionResult(res)).notToHaveProperty('errors');
|
|
345
|
+
}),
|
|
346
|
+
]),
|
|
313
347
|
...['string', 0, false, ['array']].map((invalid) => audit(
|
|
314
348
|
// TODO: convert to MUST after watershed
|
|
315
349
|
`SHOULD use 400 status code on ${extendedTypeof(invalid)} {variables} parameter when accepting application/graphql-response+json`, async () => {
|
|
@@ -689,8 +723,8 @@ export async function auditServer(opts) {
|
|
|
689
723
|
}
|
|
690
724
|
/** @private */
|
|
691
725
|
async function getUrl(url) {
|
|
692
|
-
if (typeof url === '
|
|
693
|
-
return url;
|
|
726
|
+
if (typeof url === 'function') {
|
|
727
|
+
return await url();
|
|
694
728
|
}
|
|
695
|
-
return
|
|
729
|
+
return url;
|
|
696
730
|
}
|
package/package.json
CHANGED
|
Binary file
|