@as-integrations/koa
Advanced tools
Comparing version 0.0.12 to 0.1.0
@@ -31,15 +31,17 @@ "use strict"; | ||
}; | ||
Object.entries(Object.fromEntries(headers)); | ||
try { | ||
const httpGraphQLResponse = await server.executeHTTPGraphQLRequest({ | ||
const { body, headers, status } = await server.executeHTTPGraphQLRequest({ | ||
httpGraphQLRequest, | ||
context: () => context({ ctx }), | ||
}); | ||
if (httpGraphQLResponse.completeBody === null) { | ||
throw Error('Incremental delivery not implemented'); | ||
} | ||
for (const [key, value] of httpGraphQLResponse.headers) { | ||
for (const [key, value] of headers) { | ||
ctx.set(key, value); | ||
} | ||
ctx.status = httpGraphQLResponse.status || 200; | ||
ctx.body = httpGraphQLResponse.completeBody; | ||
ctx.status = status || 200; | ||
if (body.kind === 'complete') { | ||
ctx.body = body.string; | ||
return; | ||
} | ||
throw Error('Incremental delivery not implemented'); | ||
} | ||
@@ -46,0 +48,0 @@ catch { |
{ | ||
"name": "@as-integrations/koa", | ||
"description": "Apollo server integration for koa framework", | ||
"version": "0.0.12", | ||
"version": "0.1.0", | ||
"author": "Matt Gordon <matt@greenside.tech>", | ||
@@ -42,4 +42,4 @@ "license": "MIT", | ||
"devDependencies": { | ||
"@apollo/server": "4.0.0-alpha.11", | ||
"@apollo/server-integration-testsuite": "4.0.0-alpha.11", | ||
"@apollo/server": "4.0.0-alpha.13", | ||
"@apollo/server-integration-testsuite": "4.0.0-alpha.13", | ||
"@changesets/changelog-github": "0.4.6", | ||
@@ -52,5 +52,5 @@ "@changesets/cli": "2.24.4", | ||
"@types/koa__cors": "3.3.0", | ||
"@types/node": "14.18.29", | ||
"@types/node": "14.18.31", | ||
"@types/supertest": "2.0.12", | ||
"cspell": "6.9.0", | ||
"cspell": "6.10.1", | ||
"graphql": "16.6.0", | ||
@@ -68,3 +68,3 @@ "jest": "28.1.3", | ||
"peerDependencies": { | ||
"@apollo/server": "^4.0.0-alpha.11", | ||
"@apollo/server": "^4.0.0-alpha.13", | ||
"graphql": "^16.6.0", | ||
@@ -74,5 +74,5 @@ "koa": "^2.0.0" | ||
"volta": { | ||
"node": "16.17.0", | ||
"node": "16.17.1", | ||
"npm": "8.19.2" | ||
} | ||
} |
@@ -83,4 +83,6 @@ import type { WithRequired } from '@apollo/utils.withrequired'; | ||
Object.entries(Object.fromEntries(headers)); | ||
try { | ||
const httpGraphQLResponse = await server.executeHTTPGraphQLRequest({ | ||
const { body, headers, status } = await server.executeHTTPGraphQLRequest({ | ||
httpGraphQLRequest, | ||
@@ -90,13 +92,14 @@ context: () => context({ ctx }), | ||
if (httpGraphQLResponse.completeBody === null) { | ||
// TODO(AS4): Implement incremental delivery or improve error handling. | ||
throw Error('Incremental delivery not implemented'); | ||
for (const [key, value] of headers) { | ||
ctx.set(key, value); | ||
} | ||
for (const [key, value] of httpGraphQLResponse.headers) { | ||
ctx.set(key, value); | ||
ctx.status = status || 200; | ||
if (body.kind === 'complete') { | ||
ctx.body = body.string; | ||
return; | ||
} | ||
ctx.status = httpGraphQLResponse.status || 200; | ||
ctx.body = httpGraphQLResponse.completeBody; | ||
throw Error('Incremental delivery not implemented'); | ||
} catch { | ||
@@ -103,0 +106,0 @@ await next(); |
{ | ||
"compilerOptions": { | ||
"composite": true | ||
"composite": true, | ||
}, | ||
@@ -5,0 +5,0 @@ "files": [], |
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
237
17093