Simplified server code.
This commit is contained in:
parent
0a3c7a61b0
commit
20e79ba465
@ -9,27 +9,26 @@ import graphqlTools from 'graphql-tools'
|
||||
import typeDefs from './schema.mjs'
|
||||
import resolvers from './resolvers.mjs'
|
||||
|
||||
const app = new Koa()
|
||||
const router = new KoaRouter()
|
||||
const schema = graphqlTools.makeExecutableSchema({ typeDefs, resolvers })
|
||||
|
||||
router.post(
|
||||
const router = new KoaRouter().post(
|
||||
'/graphql',
|
||||
koaBody(),
|
||||
apolloUploadKoa(),
|
||||
graphqlServerKoa.graphqlKoa({ schema })
|
||||
graphqlServerKoa.graphqlKoa({
|
||||
schema: graphqlTools.makeExecutableSchema({ typeDefs, resolvers })
|
||||
})
|
||||
)
|
||||
|
||||
app
|
||||
new Koa()
|
||||
.use(cors())
|
||||
.use(compress())
|
||||
.use(router.routes())
|
||||
.use(router.allowedMethods())
|
||||
|
||||
app.listen(process.env.PORT, error => {
|
||||
if (error) throw error
|
||||
// eslint-disable-next-line no-console
|
||||
console.info(
|
||||
`Serving http://localhost:${process.env.PORT} for ${process.env.NODE_ENV}.`
|
||||
)
|
||||
})
|
||||
.listen(process.env.PORT, error => {
|
||||
if (error) throw error
|
||||
// eslint-disable-next-line no-console
|
||||
console.info(
|
||||
`Serving http://localhost:${process.env.PORT} for ${
|
||||
process.env.NODE_ENV
|
||||
}.`
|
||||
)
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user