2016-12-13 11:32:23 +09:00
|
|
|
import { GraphQLSchema } from 'meteor/nova:lib';
|
2016-11-03 21:39:09 +09:00
|
|
|
|
2016-10-31 16:19:37 +01:00
|
|
|
import { makeExecutableSchema } from 'graphql-tools';
|
2016-10-28 18:09:41 +02:00
|
|
|
|
2016-12-23 20:58:10 +01:00
|
|
|
import { meteorClientConfig } from './client.js';
|
2016-10-28 18:09:41 +02:00
|
|
|
|
|
|
|
import { createApolloServer } from './server.js';
|
2016-11-18 16:01:27 +09:00
|
|
|
import generateTypeDefs from './schema';
|
2016-11-03 21:39:09 +09:00
|
|
|
|
2017-01-21 10:28:19 +09:00
|
|
|
import OpticsAgent from 'optics-agent'
|
|
|
|
|
2016-11-18 16:01:27 +09:00
|
|
|
Meteor.startup(function () {
|
|
|
|
const typeDefs = generateTypeDefs();
|
|
|
|
|
2016-12-12 10:41:50 +09:00
|
|
|
GraphQLSchema.finalSchema = typeDefs;
|
2016-11-18 16:01:27 +09:00
|
|
|
|
|
|
|
const schema = makeExecutableSchema({
|
|
|
|
typeDefs,
|
2016-12-12 10:41:50 +09:00
|
|
|
resolvers: GraphQLSchema.resolvers,
|
2016-11-18 16:01:27 +09:00
|
|
|
});
|
2017-01-18 12:51:10 +01:00
|
|
|
|
2017-01-21 10:28:19 +09:00
|
|
|
if (process.env.OPTICS_API_KEY) {
|
|
|
|
OpticsAgent.instrumentSchema(schema)
|
|
|
|
}
|
|
|
|
|
2017-01-18 12:51:10 +01:00
|
|
|
// uncomment for debug
|
|
|
|
// console.log('// --> starting graphql server');
|
|
|
|
|
2016-11-18 16:01:27 +09:00
|
|
|
createApolloServer({
|
|
|
|
schema,
|
|
|
|
});
|
2016-10-28 18:09:41 +02:00
|
|
|
});
|
|
|
|
|
2016-12-23 20:58:10 +01:00
|
|
|
export { meteorClientConfig };
|