const typeDefs = `
type User {
_id: ID!
email: String
jwt: String
}
type Query {
currentUser: User
}
`;
const resolvers = {
Query: {
currentUser: (root, args, ctx) => {
console.log(ctx.foo); // IT'S NOT HERE?
},
},
};
export const schema = makeExecutableSchema({
typeDefs,
resolvers,
});
When I run query currentUser I would expect the context to have been passed from Gateway => Auth to console.log out 'bar', but Auth's ctx.foo is undefined.
EDIT: I realized I can pass it through the header like so 🎉 :
This question originates from: https://github.com/apollographql/apollo-server/issues/780 about trying to build an Auth microservice and keeping the current user context from Gateway => Auth.
I read about Apollo Link and think it might be what I need. I tried the following:
Gateway schema
Auth schema
When I run
query currentUser
I would expect the context to have been passed from Gateway => Auth to console.log out 'bar', but Auth'sctx.foo
is undefined.EDIT: I realized I can pass it through the header like so 🎉 :
Can this only be done if I pass it through the header? The following makes me think that's the case:
Where the
contextFunction
only has access to therequest.headers
and secrets, but not the full Gateway context.