From 7df551eba8ec8aa00243d91746e5f28c4d755837 Mon Sep 17 00:00:00 2001 From: Michal Piechowiak Date: Fri, 20 Apr 2018 19:29:09 +0200 Subject: [PATCH] update relay-compiler (#5041) Signed-off-by: Michal Piechowiak --- packages/gatsby/package.json | 10 +++++----- .../query-runner/query-compiler.js | 15 ++++++++++----- packages/gatsby/src/utils/eslint-config.js | 2 +- packages/graphql-skip-limit/package.json | 2 +- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/packages/gatsby/package.json b/packages/gatsby/package.json index 859b7d4012102..f34272aa3d8ca 100644 --- a/packages/gatsby/package.json +++ b/packages/gatsby/package.json @@ -49,7 +49,7 @@ "eslint-config-react-app": "^2.1.0", "eslint-loader": "^2.0.0", "eslint-plugin-flowtype": "^2.46.1", - "eslint-plugin-graphql": "^1.5.0", + "eslint-plugin-graphql": "^2.0.0", "eslint-plugin-import": "^2.9.0", "eslint-plugin-jsx-a11y": "^5.1.1", "eslint-plugin-react": "^7.7.0", @@ -65,8 +65,8 @@ "gatsby-link": "^1.6.38-3", "gatsby-react-router-scroll": "^1.0.12-2", "glob": "^7.1.1", - "graphql": "^0.11.7", - "graphql-relay": "^0.5.1", + "graphql": "^0.13.2", + "graphql-relay": "^0.5.5", "graphql-skip-limit": "^1.0.11-2", "history": "^4.6.2", "invariant": "^2.2.4", @@ -107,7 +107,7 @@ "react-router": "^4.1.1", "react-router-dom": "^4.1.1", "redux": "^3.6.0", - "relay-compiler": "1.4.1", + "relay-compiler": "1.5.0", "remote-redux-devtools": "^0.5.7", "serve": "^6.5.3", "shallow-compare": "^1.2.2", @@ -174,7 +174,7 @@ "url": "git+https://github.com/gatsbyjs/gatsby.git" }, "resolutions": { - "graphql": "^0.11.7" + "graphql": "^0.13.2" }, "scripts": { "build": "rimraf dist && npm run build:src && npm run build:internal-plugins && npm run build:rawfiles", diff --git a/packages/gatsby/src/internal-plugins/query-runner/query-compiler.js b/packages/gatsby/src/internal-plugins/query-runner/query-compiler.js index b81580b0138e4..4cc61cd7cf262 100644 --- a/packages/gatsby/src/internal-plugins/query-runner/query-compiler.js +++ b/packages/gatsby/src/internal-plugins/query-runner/query-compiler.js @@ -26,8 +26,8 @@ import type { DocumentNode, GraphQLSchema } from "graphql" const { printTransforms } = IRTransforms const { - ArgumentsOfCorrectTypeRule, - DefaultValuesOfCorrectTypeRule, + ValuesOfCorrectTypeRule, + VariablesDefaultValueAllowedRule, FragmentsOnCompositeTypesRule, KnownTypeNamesRule, LoneAnonymousOperationRule, @@ -46,8 +46,8 @@ type RootQuery = { type Queries = Map const validationRules = [ - ArgumentsOfCorrectTypeRule, - DefaultValuesOfCorrectTypeRule, + ValuesOfCorrectTypeRule, + VariablesDefaultValueAllowedRule, FragmentsOnCompositeTypesRule, KnownTypeNamesRule, LoneAnonymousOperationRule, @@ -146,7 +146,12 @@ class Runner { return compiledNodes } - const printContext = printTransforms.reduce( + // relay-compiler v1.5.0 added "StripUnusedVariablesTransform" to + // printTransforms. Unfortunately it currently doesn't detect variables + // in input objects widely used in gatsby, and therefore removing + // variable declaration from queries. + // As a temporary workaround remove that transform by slicing printTransforms. + const printContext = printTransforms.slice(0, -1).reduce( (ctx, transform) => transform(ctx, this.schema), compilerContext ) diff --git a/packages/gatsby/src/utils/eslint-config.js b/packages/gatsby/src/utils/eslint-config.js index 4e3e9ce5a640c..06792529c70df 100644 --- a/packages/gatsby/src/utils/eslint-config.js +++ b/packages/gatsby/src/utils/eslint-config.js @@ -14,7 +14,7 @@ module.exports = schema => { `error`, { env: `relay`, - schemaString: printSchema(schema), + schemaString: printSchema(schema, { commentDescriptions: true }), tagName: `graphql`, }, ], diff --git a/packages/graphql-skip-limit/package.json b/packages/graphql-skip-limit/package.json index ab05342e3a6ca..801e0664c3d75 100644 --- a/packages/graphql-skip-limit/package.json +++ b/packages/graphql-skip-limit/package.json @@ -13,7 +13,7 @@ "@babel/cli": "^7.0.0-beta.42", "@babel/core": "^7.0.0-beta.42", "cross-env": "^5.1.4", - "graphql": "^0.11.7" + "graphql": "^0.13.2" }, "homepage": "https://github.com/gatsbyjs/gatsby/tree/master/packages/graphql-skip-limit#readme", "keywords": [