-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
36 lines (28 loc) · 1007 Bytes
/
index.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
const { ApolloServer } = require("apollo-server");
const { importSchema } = require("graphql-import");
const EtherDataSource = require("./datasource/ethDatasource");
const typeDefs = importSchema("./schema.graphql");
require("dotenv").config();
const resolvers = {
Query: {
etherBalanceByAddress: (root, _args, { dataSources }) =>
dataSources.ethDataSource.etherBalanceByAddress(),
totalSupplyOfEther: (root, _args, { dataSources }) =>
dataSources.ethDataSource.totalSupplyOfEther(),
latestEthereumPrice: (root, _args, { dataSources }) =>
dataSources.ethDataSource.getLatestEthereumPrice(),
blockConfirmationTime: (root, _args, { dataSources }) =>
dataSources.ethDataSource.getBlockConfirmationTime(),
},
};
const server = new ApolloServer({
typeDefs,
resolvers,
dataSources: () => ({
ethDataSource: new EtherDataSource(),
}),
});
server.timeout = 0;
server.listen("9000").then(({ url }) => {
console.log(`🚀 Server ready at ${url}`);
});