mirror of
https://github.com/vale981/Vulcan
synced 2025-03-06 10:01:40 -05:00
setup engine
This commit is contained in:
parent
29bcf74ed3
commit
ad022bce9b
3 changed files with 16 additions and 70 deletions
|
@ -32,7 +32,7 @@ import cookiesMiddleware from 'universal-cookie-express';
|
|||
export let executableSchema;
|
||||
|
||||
import './settings';
|
||||
import { engine, engineApiKey } from './engine';
|
||||
import { engineConfig } from './engine';
|
||||
import { defaultConfig, defaultOptions } from './defaults';
|
||||
import computeContext from './computeContext';
|
||||
|
||||
|
@ -47,13 +47,12 @@ const createApolloServer = ({ options: givenOptions = {}, config: givenConfig =
|
|||
const options = { ...defaultOptions, ...givenOptions };
|
||||
// given options contains the schema
|
||||
const apolloServer = new ApolloServer({
|
||||
engine: engineConfig,
|
||||
...options,
|
||||
// this replace the previous syntax graphqlExpress(async req => { ... })
|
||||
// this function takes the context, which contains the current request,
|
||||
// and setup the options accordingly ({req}) => { ...; return options }
|
||||
context: computeContext(options.context, contextFromReq)
|
||||
// TODO: we could split options that actually need the request/result and others
|
||||
// (eg schema, formatError, etc.)
|
||||
});
|
||||
|
||||
// default function does nothing
|
||||
|
@ -61,10 +60,6 @@ const createApolloServer = ({ options: givenOptions = {}, config: givenConfig =
|
|||
config.configServer({ apolloServer });
|
||||
|
||||
// setup middleware
|
||||
// TODO: might not be needed anymore
|
||||
//if (engineApiKey) {
|
||||
// app.use(engine.expressMiddleware());
|
||||
//}
|
||||
//// TODO: use a graphqlish solution?
|
||||
//app.use(cookiesMiddleware());
|
||||
//// TODO: is it needed?
|
||||
|
@ -88,6 +83,7 @@ const createApolloServer = ({ options: givenOptions = {}, config: givenConfig =
|
|||
res.end();
|
||||
}
|
||||
});
|
||||
// TODO: previous implementation with a patch. Is it still needed?
|
||||
//webAppConnectHandlersUse(Meteor.bindEnvironment(apolloServer), {
|
||||
// name: 'graphQLServerMiddleware_bindEnvironment',
|
||||
// order: 30
|
||||
|
|
|
@ -1,58 +1,8 @@
|
|||
import { Engine } from 'apollo-engine';
|
||||
import { getSetting } from '../../modules/settings.js';
|
||||
// see https://github.com/apollographql/apollo-cache-control
|
||||
const engineApiKey = getSetting('apolloEngine.apiKey');
|
||||
const engineLogLevel = getSetting('apolloEngine.logLevel', 'INFO');
|
||||
const engineConfig = {
|
||||
apiKey: engineApiKey,
|
||||
// "origins": [
|
||||
// {
|
||||
// "http": {
|
||||
// "url": "http://localhost:3000/graphql"
|
||||
// }
|
||||
// }
|
||||
// ],
|
||||
stores: [
|
||||
{
|
||||
name: 'vulcanCache',
|
||||
inMemory: {
|
||||
cacheSize: 20000000
|
||||
}
|
||||
}
|
||||
],
|
||||
// "sessionAuth": {
|
||||
// "store": "embeddedCache",
|
||||
// "header": "Authorization"
|
||||
// },
|
||||
// "frontends": [
|
||||
// {
|
||||
// "host": "127.0.0.1",
|
||||
// "port": 3000,
|
||||
// "endpoint": "/graphql",
|
||||
// "extensions": {
|
||||
// "strip": []
|
||||
// }
|
||||
// }
|
||||
// ],
|
||||
queryCache: {
|
||||
publicFullQueryStore: 'vulcanCache',
|
||||
privateFullQueryStore: 'vulcanCache'
|
||||
},
|
||||
// "reporting": {
|
||||
// "endpointUrl": "https://engine-report.apollographql.com",
|
||||
// "debugReports": true
|
||||
// },
|
||||
logging: {
|
||||
level: engineLogLevel
|
||||
}
|
||||
};
|
||||
let engine;
|
||||
if (engineApiKey) {
|
||||
engine = new Engine({ engineConfig });
|
||||
engine.start();
|
||||
}
|
||||
|
||||
export default {
|
||||
engine,
|
||||
engineApiKey
|
||||
export const engineApiKey = process.env.ENGINE_API_KEY || getSetting('apolloEngine.apiKey');
|
||||
// options now available:
|
||||
// @see https://www.apollographql.com/docs/apollo-server/api/apollo-server.html#EngineReportingOptions
|
||||
export const engineConfig = {
|
||||
apiKey: engineApiKey
|
||||
};
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { registerSetting } from '../../modules/settings.js';
|
||||
|
||||
registerSetting('apolloEngine.logLevel', 'INFO', 'Log level (one of INFO, DEBUG, WARN, ERROR');
|
||||
registerSetting(
|
||||
'apolloTracing',
|
||||
Meteor.isDevelopment,
|
||||
'Tracing by Apollo. Default is true on development and false on prod',
|
||||
true
|
||||
);
|
||||
// TODO: is this still necessary?
|
||||
//registerSetting('apolloEngine.logLevel', 'INFO', 'Log level (one of INFO, DEBUG, WARN, ERROR');
|
||||
//registerSetting(
|
||||
// 'apolloTracing',
|
||||
// Meteor.isDevelopment,
|
||||
// 'Tracing by Apollo. Default is true on development and false on prod',
|
||||
// true
|
||||
//);
|
||||
|
|
Loading…
Add table
Reference in a new issue