import { graphqlKoa, graphiqlKoa } from 'apollo-server-koa';
router.post('/graphql', koaBody(), graphqlKoa({ schema: schemas.UserSchema, formatError }));
i want to get ctx using following method:
async resolve (root, params, options, ctx) {}
how can i do that?
Is resolve a resolver inside your schema?
I asume that you are using graphql-tools, therefore https://www.apollographql.com/docs/graphql-tools/resolvers.html#Resolver-function-signature should be relevant to you.
I have solved this fucking problem with a fucking strange method:
router.post('/graphql', koaBody(), (ctx, next) => graphqlKoa({ schema: schemas.EmailSchema, formatError, context: ctx })(ctx, next));
Then I can use ctx in fn resolve:
async resolve (root, params, ctx) {
// use ctx
}
Oh, I did not know you mean the koa context object 馃槄
Glad you figured it out!
Most helpful comment
I have solved this
fuckingproblem with afuckingstrange method:Then I can use
ctxin fnresolve: