Following the upgrade to Apollo v4 and migration guide, my project was functioning properly.
However, the context is now undefined.
const { url } = await startStandaloneServer(server, {
listen: { port: 3000 },
context: async ({ req }) => {
try {
const { token } = req.headers
console.log(`Token: ${token}`)
return { token }
} catch {
return {}
}
},
})
Switching to
return { context: { token } }
Doesn't seem to solve the issue.
In this scenario, the context is undefined
export const myAuthChecker: AuthChecker<MyContext> = ({ context: { token } }) => {
if (token) {
return true
}
return false
}
What could I be overlooking?
For a minimal reproducible example visit https://github.com/skhaz/graphql-auth