-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
↩️ Switch graphql-yoga to apollo-server
- Loading branch information
1 parent
32e8e20
commit efbcaef
Showing
1 changed file
with
17 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,25 @@ | ||
import { GraphQLServer } from 'graphql-yoga' | ||
import { prisma } from './generated/prisma-client' | ||
import { ApolloServer, gql } from 'apollo-server' | ||
import { importSchema } from 'graphql-import' | ||
import { Prisma } from './generated/prisma-client' | ||
import resolvers from './resolvers' | ||
|
||
const server = new GraphQLServer({ | ||
typeDefs: './src/schema.graphql', | ||
const { APP_SECRET, PORT, PRISMA_ENDPOINT } = process.env | ||
|
||
const prisma = new Prisma({ | ||
endpoint: PRISMA_ENDPOINT, | ||
secret: APP_SECRET, | ||
debug: true | ||
}) | ||
|
||
const importedTypeDefs = importSchema(__dirname + '/schema.graphql') | ||
const typeDefs = gql`${importedTypeDefs}` | ||
|
||
const server = new ApolloServer({ | ||
typeDefs, | ||
resolvers, | ||
context: req => ({ ...req, prisma }) | ||
}) | ||
|
||
const { PORT } = process.env | ||
|
||
server | ||
.start({ port: PORT }, () => console.log(`🚀 Server is running on http://localhost:${PORT}`)) | ||
.listen({ port: PORT }, () => console.log(`🚀 Server is running on http://localhost:${PORT}`)) | ||
.catch(err => console.error(err)) |