|
1 | | -const { ApolloServer, gql } = require("apollo-server") |
2 | | -const { Prisma } = require("prisma-binding") |
3 | | -const { importSchema } = require("graphql-import") |
4 | | -const resolvers = require("./resolvers") |
| 1 | +const { ApolloServer, makeExecutableSchema } = require('apollo-server'); |
| 2 | +const { Prisma } = require('prisma-binding'); |
| 3 | +const { importSchema } = require('graphql-import'); |
5 | 4 |
|
6 | | -const server = new ApolloServer({ |
7 | | - typeDefs: importSchema("./src/schema.graphql"), |
| 5 | +const typeDefs = importSchema('./src/schema.graphql'); |
| 6 | +const resolvers = require('./resolvers'); |
| 7 | +const schema = makeExecutableSchema({ |
| 8 | + typeDefs, |
8 | 9 | resolvers, |
| 10 | + resolverValidationOptions: { |
| 11 | + requireResolversForResolveType: false, |
| 12 | + }, |
| 13 | +}); |
| 14 | + |
| 15 | +const server = new ApolloServer({ |
| 16 | + schema, |
9 | 17 | context: req => ({ |
10 | 18 | ...req, |
11 | 19 | db: new Prisma({ |
12 | | - typeDefs: "./src/generated/prisma.graphql", // the auto-generated GraphQL schema of the Prisma API |
| 20 | + typeDefs: './src/generated/prisma.graphql', // the auto-generated GraphQL schema of the Prisma API |
13 | 21 | endpoint: process.env.PRISMA_ENDPOINT, // the endpoint of the Prisma API |
14 | 22 | debug: true, // log all GraphQL queries & mutations sent to the Prisma API |
15 | 23 | // secret: process.env.PRISMA_SECRET, // only needed if specified in `database/prisma.yml` |
16 | 24 | }), |
17 | 25 | }), |
18 | | -}) |
| 26 | +}); |
19 | 27 |
|
20 | | -server.listen().then(({ url }) => `🚀 Server ready at ${url}`) |
| 28 | +server.listen().then(({ url }) => `🚀 Server ready at ${url}`); |
0 commit comments