Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
"eslint-config-airbnb": "^3.1.0",
"eslint-plugin-react": "^3.14.0",
"expect.js": "^0.3.1",
"graphql-crunch": "^1.1.2",
"husky": "^0.13.3",
"jest": "^22.4.2",
"lint-staged": "^3.4.0",
Expand Down
7 changes: 7 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import moment from "moment"
import morgan from "artsy-morgan"
import raven from "raven"
import xapp from "artsy-xapp"
import { crunch } from "graphql-crunch"
import {
fetchLoggerSetup,
fetchLoggerRequestDone,
Expand Down Expand Up @@ -124,6 +125,12 @@ async function startApp() {
enableSentry,
isProduction,
}),
formatResponse: resp => {
if (req.query.crunch && resp.data && !resp.data.__schema) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only apply when

  1. crunch is supplied as a query param
  2. There's actual data to return
  3. The current response isn't an introspection query

resp.data = crunch(resp.data) // eslint-disable-line no-param-reassign
}
return resp
},
validationRules: [depthLimit(queryLimit)],
extensions: enableRequestLogging
? fetchLoggerRequestDone(requestID)
Expand Down
4 changes: 4 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2800,6 +2800,10 @@ graphiql@^0.11.11:
codemirror-graphql "^0.6.11"
markdown-it "^8.4.0"

graphql-crunch@^1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/graphql-crunch/-/graphql-crunch-1.1.2.tgz#8c8e686d1cb92b55f779fdf902c99ac644280c15"

graphql-depth-limit@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/graphql-depth-limit/-/graphql-depth-limit-1.1.0.tgz#59fe6b2acea0ab30ee7344f4c75df39cc18244e8"
Expand Down