-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
42 lines (33 loc) · 888 Bytes
/
server.js
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
37
38
39
40
41
42
require("dotenv").config();
const { PORT, BASE_ID, API_KEY } = process.env;
const { makeExecutableSchema } = require("graphql-tools");
const { printSchema } = require("graphql");
const { ApolloServer, gql } = require("apollo-server");
const AirtableGraphQL = require("@draftbit/airtable-graphql");
const schema = require("./schema.json");
const ag = new AirtableGraphQL({
schema,
base: BASE_ID,
apiKey: API_KEY
});
const baseSchema = makeExecutableSchema({
typeDefs: printSchema(ag.schema),
resolvers: ag.resolvers
});
async function start() {
const schema = baseSchema
const server = new ApolloServer({
schema,
playground: true,
introspection: true,
});
server.listen({ port: PORT || 8080 }).then(({ url }) => {
console.log(`🚀 Server ready at ${url}`);
});
}
try {
start();
} catch (error) {
console.error(error);
process.exit(1);
}