Reputation: 18451
I'm building the following route on my express middleware:
app.use(
"/graphql",
passport.authenticate("jwt", { session: false }),
appGraphQL()
);
The route goes through passport for validation and then calls my GraphQL server.
My GraphQL server entry code is:
export default (req, res) => {
console.log("RECEIVED PARAMETERS:")
console.log(req)
console.log(res)
return graphqlHTTP({
schema: schema,
graphiql: true,
pretty: true,
context: {
resolvers: null, // Will add my resolvers here
req: req,
res: res
},
formatError: error => ({
message: error.message,
locations: error.locations,
stack: error.stack,
path: error.path
})
});
};
I'm getting null as req
and res
parameters.
How can I properly send req
and res
to my GraphQL code?
Upvotes: 0
Views: 43
Reputation: 21317
You are immediately executing appGraphQL
app.use(
"/graphql",
passport.authenticate("jwt", { session: false }),
(req,res) => appGraphQL(req,res)
);
Upvotes: 1