Closed acarl005 closed 7 years ago
IMO, this should be done by one of middleware before koa-graphql
middleware:
app.use(async (ctx, next) => {
await next();
ctx.body = Object.assign({}, ctx.body, {
// some others...
});
});
app.use(graphqlHTTP({
schema: MyGraphQLSchema,
}));
This is how koa middleware works. Otherwise, we must rewrite every middleware to support merging body.
Hello. This module works pretty well. I am suggesting an enhancement. After executing and resolving GraphQL, the results are assigned to the
response.body
https://github.com/chentsulin/koa-graphql/blob/master/src/index.js#L294-L296.This will overwrite any other information that the server might have set. There may be additional information we want to send down that isn't part of the schema. Perhaps instead of a reassignment, it could attempt an object merge so that the developer can send down other information. I've put in PR #103 for this suggestion.