I'm using apollo-server-koa
and created a simple Koa app + ApolloServer but when I want to access ctx.cookies
in the GraphQL resolvers, it's always undefined
. Only request
and response
are there.
const app = new Koa()
const server = new ApolloServer({
schema,
context: ({ ctx }) => ctx
})
server.applyMiddleware({
app,
cors: {
origin: 'http://localhost:3000',
credentials: true,
}
})
It confuses me because when I do app.use((ctx) => ...)
, cookies
is available.
Is this correct and do I need a separate cookie middleware like cookie-parser
in express?