graphql-http
Advanced tools
Comparing version 1.7.1 to 1.7.2
@@ -45,5 +45,3 @@ "use strict"; | ||
}), | ||
(0, utils_1.audit)( | ||
// TODO: convert to MUST after watershed | ||
'SHOULD accept */* and use application/graphql-response+json for the content-type', async () => { | ||
(0, utils_1.audit)('SHOULD accept */* and use application/json for the content-type', async () => { | ||
const res = await fetchFn(opts.url, { | ||
@@ -58,16 +56,10 @@ method: 'POST', | ||
(0, utils_1.assert)('Status code', res.status).toBe(200); | ||
(0, utils_1.assert)('Content-Type header', res.headers.get('content-type')).toContain('application/graphql-response+json'); | ||
(0, utils_1.assert)('Content-Type header', res.headers.get('content-type')).toContain('application/json'); | ||
}), | ||
(0, utils_1.audit)( | ||
// TODO: convert to MUST after watershed | ||
'SHOULD assume application/graphql-response+json content-type when accept is missing', async () => { | ||
const res = await fetchFn(opts.url, { | ||
method: 'POST', | ||
headers: { | ||
'content-type': 'application/json', | ||
}, | ||
body: JSON.stringify({ query: '{ __typename }' }), | ||
}); | ||
(0, utils_1.audit)('SHOULD assume application/json content-type when accept is missing', async () => { | ||
const url = new URL(opts.url); | ||
url.searchParams.set('query', '{ __typename }'); | ||
const res = await fetchFn(url.toString()); | ||
(0, utils_1.assert)('Status code', res.status).toBe(200); | ||
(0, utils_1.assert)('Content-Type header', res.headers.get('content-type')).toContain('application/graphql-response+json'); | ||
(0, utils_1.assert)('Content-Type header', res.headers.get('content-type')).toContain('application/json'); | ||
}), | ||
@@ -168,2 +160,3 @@ (0, utils_1.audit)('MUST use utf-8 encoding when responding', async () => { | ||
(0, utils_1.audit)('MUST require a request body on POST', async () => { | ||
var _a; | ||
const res = await fetchFn(opts.url, { | ||
@@ -173,3 +166,8 @@ method: 'POST', | ||
}); | ||
(0, utils_1.assert)('Status code', res.status).toBe(400); | ||
if ((_a = res.headers.get('content-type')) === null || _a === void 0 ? void 0 : _a.includes('application/json')) { | ||
(0, utils_1.assert)('Execution result', await (0, utils_1.assertBodyAsExecutionResult)(res)).toHaveProperty('errors'); | ||
} | ||
else { | ||
(0, utils_1.assert)('Status code', res.status).toBe(400); | ||
} | ||
}), | ||
@@ -176,0 +174,0 @@ // Request Parameters |
@@ -299,11 +299,12 @@ "use strict"; | ||
const charset = (params === null || params === void 0 ? void 0 : params.find((param) => param.includes('charset='))) || 'charset=utf8'; // utf-8 is assumed when not specified; | ||
if (mediaType === 'application/json' && charset === 'charset=utf8') { | ||
acceptedMediaType = 'application/json'; | ||
if (mediaType === 'application/graphql-response+json' && | ||
charset === 'charset=utf8') { | ||
acceptedMediaType = 'application/graphql-response+json'; | ||
break; | ||
} | ||
if ((mediaType === 'application/graphql-response+json' || | ||
if ((mediaType === 'application/json' || | ||
mediaType === 'application/*' || | ||
mediaType === '*/*') && | ||
charset === 'charset=utf8') { | ||
acceptedMediaType = 'application/graphql-response+json'; | ||
acceptedMediaType = 'application/json'; | ||
break; | ||
@@ -310,0 +311,0 @@ } |
{ | ||
"name": "graphql-http", | ||
"version": "1.7.1", | ||
"version": "1.7.2", | ||
"description": "Simple, pluggable, zero-dependency, GraphQL over HTTP Protocol compliant server and client", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -732,9 +732,9 @@ <div align="center"> | ||
| Name | Audit | | ||
| ------------------------------------------------------------------ | -------------------------------------------------------------------- | | ||
| [graphql-yoga](https://www.the-guild.dev/graphql/yoga-server) | [✅ Compliant (0 warnings)](/implementations/graphql-yoga/README.md) | | ||
| [hotchocolate](https://chillicream.com/docs/hotchocolate) | [✅ Compliant (0 warnings)](/implementations/hotchocolate/README.md) | | ||
| [postgraphile](https://www.graphile.org/postgraphile/) | [✅ Compliant](/implementations/postgraphile/README.md) | | ||
| [apollo-server](https://www.apollographql.com/docs/apollo-server/) | [✅ Compliant](/implementations/apollo-server/README.md) | | ||
| [mercurius](https://mercurius.dev) | [✅ Compliant](/implementations/mercurius/README.md) | | ||
| Name | Audit | | ||
| ------------------------------------------------------------------ | -------------------------------------------------------- | | ||
| [graphql-yoga](https://www.the-guild.dev/graphql/yoga-server) | [✅ Compliant](/implementations/graphql-yoga/README.md) | | ||
| [hotchocolate](https://chillicream.com/docs/hotchocolate) | [✅ Compliant](/implementations/hotchocolate/README.md) | | ||
| [postgraphile](https://www.graphile.org/postgraphile/) | [✅ Compliant](/implementations/postgraphile/README.md) | | ||
| [apollo-server](https://www.apollographql.com/docs/apollo-server/) | [✅ Compliant](/implementations/apollo-server/README.md) | | ||
| [mercurius](https://mercurius.dev) | [✅ Compliant](/implementations/mercurius/README.md) | | ||
@@ -741,0 +741,0 @@ ## [Documentation](docs/) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
235307
4357