After upgrading to Apollo v4, following the migration guide, I used to have a working project.
Now, the context is 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 {}
}
},
})
Changing to
return { context: { token } }
Does't not help.
Here, context is undefined
export const myAuthChecker: AuthChecker<MyContext> = ({ context: { token } }) => {
if (token) {
return true
}
return false
}
What am I missing?
Minimal reproducible example https://github.com/skhaz/graphql-auth
I downloaded your package and fixed your issue.
You have to update your tsconfig with at least this target version:
"target": "es2018",