Team,
I am facing an issue on context undefined with the graphql resolver,when using with the apollo server .This is the code used.
return new ApolloServer({
schema,
context: ({ req}) => ({
req
}),
playground:true,
introspection: true
});
Thanks and appreciate your help...
Hi @manojkumaraut,
Perhaps you already found it, but you can directly return the request data like this:
context: ({ req }) => req
Did you figure this out @manojkumaraut ? same problem here.
@dep-dt
It's been some time, but if I remember correctly the code below worked for me
ApolloServer({
schema,
context: ({ req }) => req,
playground:true,
introspection: true
});
Ran into a similar issue. Restarting the server worked for me
Still struggling with this - anyone got a solution?
My issue was how I was forming the actual context.
Bad, doesn't work for me:
const server = new ApolloServer({
schema,
dataSources,
context: ({ req }) => {
console.log(req);
},
});
Good:
const server = new ApolloServer({
schema,
dataSources,
context: req => {
console.log(req);
},
});
And then you should be able to test this using something like curl from the command line.
â–¶ curl \
-X POST \
--data '{ "query": "{ foo { bar } }" }' \
http://localhost:4000/graphql
Good luck out there!