Skip to content

Commit

Permalink
Maintain use of context.done(), but use isRaw instead.
Browse files Browse the repository at this point in the history
Per the Azure documentation regarding the response object available at:

https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-node#response-object
  • Loading branch information
abernix committed Apr 17, 2018
1 parent 19bb1dc commit 7c23e64
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions packages/apollo-server-azure-functions/src/azureFunctionsApollo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,16 @@ export function graphqlAzureFunctions(

return runHttpQuery([httpContext, request], queryRequest)
.then(gqlResponse => {
httpContext.res.setHeader('Content-Type', 'application/json');
httpContext.res.raw(gqlResponse);
const result = {
status: HttpStatusCodes.OK,
headers: {
'Content-Type': 'application/json',
},
body: gqlResponse,
isRaw: true,
};
httpContext.res = result;
httpContext.done(null, result);
})
.catch(error => {
const result = {
Expand Down Expand Up @@ -98,8 +106,16 @@ export function graphiqlAzureFunctions(

resolveGraphiQLString(query, options, httpContext, request).then(
graphiqlString => {
httpContext.res.setHeader('Content-Type', 'text/html; charset-utf-8');
httpContext.res.raw(graphiqlString);
const result = {
status: HttpStatusCodes.OK,
headers: {
'Content-Type': 'text/html',
},
body: graphiqlString,
isRaw: true,
};
httpContext.res = result;
httpContext.done(null, result);
},
error => {
httpContext.res = {
Expand Down

0 comments on commit 7c23e64

Please sign in to comment.