-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapollo-instance.js
43 lines (38 loc) · 990 Bytes
/
apollo-instance.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
const {ApolloServer} = require('apollo-server-express');
const {PrismaClient} = require('@prisma/client');
const queries = require('./lib/typeDefs/Query');
const mutations = require('./lib/typeDefs/Mutation');
const users = require('./lib/resolver/users');
const feeds = require('./lib/resolver/feeds');
const schema = require('./lib/schema/_schema');
const prisma = new PrismaClient();
const typeDefs = [
queries,
mutations,
schema.typeDefs
]
const resolvers = [
users.resolvers,
feeds.resolvers
]
const testServer = new ApolloServer({
typeDefs,
resolvers,
context: () => {
const {request: req} = require('express')
// req.headers['authorization'] = `Bearer ${process.env.JWT_TEST_TOKEN}`
return {
req, prisma
}
}
})
const apollo = new ApolloServer({
typeDefs,
resolvers,
context: ({req}) => {
return {
req, prisma
}
}
})
module.exports = {apollo, testServer}