-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsubscriptions.js
More file actions
36 lines (30 loc) · 828 Bytes
/
subscriptions.js
File metadata and controls
36 lines (30 loc) · 828 Bytes
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
require('dotenv').config();
const { PRISMA_ENDPOINT: endpoint } = process.env;
import { GraphQLServer } from 'graphql-yoga';
import path from 'path';
// ... or using `require()`
// const { GraphQLServer } = require('graphql-yoga')
const typeDefs = `
type Query {
hello(name: String): String!
}
`;
const resolvers = {
Query: {
hello: (_, { name }) => `Hello ${name || 'World'}`
}
};
const schema = path.resolve(__dirname, './prisma/generated/prisma.graphql');
const server = new GraphQLServer({ typeDefs, resolvers });
// const server = new GraphQLServer({ schema });
const options = {
port: 8000,
endpoint,
subscriptions: '/subscriptions',
playground: '/playground'
};
server.start(options, ({ port }) =>
console.log(
`Server started, listening on port ${port} for incoming requests.`
)
);