Skip to content

Commit

Permalink
↩️ Switch graphql-yoga to apollo-server
Browse files Browse the repository at this point in the history
  • Loading branch information
frankfaustino committed Dec 21, 2018
1 parent 32e8e20 commit efbcaef
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions backend/src/index.ts
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))

0 comments on commit efbcaef

Please sign in to comment.