stacker.news/pages/api/graphql.js

29 lines
636 B
JavaScript
Raw Normal View History

2021-03-25 19:29:24 +00:00
import { ApolloServer } from 'apollo-server-micro'
import resolvers from '../../api/resolvers'
import models from '../../api/models'
2021-04-29 21:58:43 +00:00
import lnd from '../../api/lnd'
2021-03-25 19:29:24 +00:00
import typeDefs from '../../api/typeDefs'
2021-04-12 18:05:09 +00:00
import { getSession } from 'next-auth/client'
2021-03-25 19:29:24 +00:00
const apolloServer = new ApolloServer({
typeDefs,
resolvers,
2021-04-29 15:56:28 +00:00
tracing: true,
2021-04-12 18:05:09 +00:00
context: async ({ req }) => {
const session = await getSession({ req })
return {
models,
2021-04-29 21:58:43 +00:00
lnd,
2021-04-14 23:56:29 +00:00
me: session ? session.user : null
2021-04-12 18:05:09 +00:00
}
}
2021-03-25 19:29:24 +00:00
})
export const config = {
api: {
bodyParser: false
}
}
export default apolloServer.createHandler({ path: '/api/graphql' })