Skip to content

Commit

Permalink
Add Apollo Engine
Browse files Browse the repository at this point in the history
I was trying to dig into why our dashboard loads pretty slowly, but
couldn't with the limited amount of information I had.

Enabling Apollo Engine again should make it possible to track
performance problems more granularly per-resolver again. (like Optics)
  • Loading branch information
mxstbr committed Jan 10, 2018
1 parent 87b550a commit 7263903
Show file tree
Hide file tree
Showing 8 changed files with 7,289 additions and 3 deletions.
5 changes: 3 additions & 2 deletions iris/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"dependencies": {
"algoliasearch": "^3.24.7",
"apollo-engine": "^0.8.3",
"apollo-local-query": "^0.3.0",
"apollo-upload-client": "^5.1.0",
"apollo-upload-server": "^2.0.4",
Expand Down Expand Up @@ -61,6 +62,7 @@
"moment": "^2.18.1",
"node-env-file": "^0.1.8",
"node-localstorage": "^1.3.0",
"now-env": "^3.0.1",
"offline-plugin": "^4.8.4",
"optics-agent": "^1.1.2",
"passport": "^0.3.2",
Expand Down Expand Up @@ -112,8 +114,7 @@
"sw-precache-webpack-plugin": "^0.11.4",
"then-queue": "^1.3.0",
"validator": "^9.0.0",
"web-push": "^3.2.2",
"now-env": "^3.0.1"
"web-push": "^3.2.2"
},
"scripts": {
"start": "NODE_ENV=production node main.js"
Expand Down
2 changes: 2 additions & 0 deletions iris/routes/api/graphql.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ export default graphqlExpress(req => ({
user: req.user,
loaders: createLoaders(),
},
tracing: true,
cacheControl: true,
}));
13 changes: 13 additions & 0 deletions iris/routes/middlewares/engine.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// @flow
import { Engine } from 'apollo-engine';

export default new Engine({
graphqlPort: 3001,
endpoint: '/api',
engineConfig: {
logging: {
level: 'WARN',
},
apiKey: process.env.APOLLO_ENGINE_API_KEY,
},
});
8 changes: 8 additions & 0 deletions iris/routes/middlewares/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ if (process.env.NODE_ENV === 'development') {
middlewares.use(logging);
}

// Start apollo engine
if (process.env.NODE_ENV === 'production' && !process.env.FORCE_DEV) {
const engine = require('./engine').default;
console.log('Apollo Engine starting...');
engine.start();
middlewares.use(engine.expressMiddleware());
}

if (process.env.NODE_ENV === 'production' && !process.env.FORCE_DEV) {
// Raven (Sentry client) needs to come before everything else
const raven = require('shared/middlewares/raven').default;
Expand Down
Loading

0 comments on commit 7263903

Please sign in to comment.