New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relay Compiler 1.6.0 Rule Error #2428

Closed
kguller opened this Issue Apr 27, 2018 · 11 comments

Comments

Projects
None yet
7 participants
@kguller
Copy link

kguller commented Apr 27, 2018

installed the latest 1.6.0 with relay compiler fixes I was hoping to use and ran into a cryptic error that looks like it's a bug in the compiler script after logging "Writing js" in the CodegenRunner.js file and attempting to validate the validation rules in ASTConvert.js. The problem looks like missing functions in the validation rules, the error output I'm receiving is "rule is not a function". I've double checked my schema and src inputs and both look ok, I'm not sure where the rule's schema function is being set to undefined, hoping to get some help in tracing it further. I'm unable to generate any Query or Mutation files at this time using 1.6.0.

Source Code Line Error

File: graphql-compiler/lib/ASTConvert.js
Function: function convertASTDefinitions(schema, definitions, validationRules, transform)
LIne: 120 (approx, shuffled some of my local code around)
Problem: When calling validate on GraphQLValidator, the validation rules fail since some of the functions are undefined. One of them I believe is the Schema Function as I tried to substitute it and the subsequent error resulted in "Missing Schema"

Command Line

$ relay-compiler --src ./src --schema ./env/schema.graphql
HINT: pass --watch to keep watching for changes.

Command Line Error Result

Writing js
ERROR:
rule is not a function
error Command failed with exit code 100.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Debugged Console Log Output for Variable "validationRules"

[ [Function: FragmentsOnCompositeTypes],
[Function: KnownTypeNames],
[Function: LoneAnonymousOperation],
[Function: PossibleFragmentSpreads],
[Function: ScalarLeafs],
undefined,
undefined,
[Function: VariablesAreInputTypes],
[Function: VariablesInAllowedPosition],
[Function: DisallowIdAsAliasValidationRule],
[Function: KnownArgumentNames],
[Function: NoUnusedVariables],
[Function: ProvidedNonNullArguments],
[Function: UniqueArgumentNames],
[Function: UniqueFragmentNames],
[Function: UniqueInputFieldNames],
[Function: UniqueOperationNames],
[Function: UniqueVariableNames] ]

@kguller kguller changed the title Relay 1.6.0 Rule Relay Compiler 1.6.0 Rule Error Apr 27, 2018

@kassens

This comment has been minimized.

Copy link
Member

kassens commented Apr 27, 2018

What version of graphql are you using? I've updated the Relay TodoMVC example to 1.6.0 and I'm not getting the error there.

Mind testing if that project also breaks for you? https://github.com/relayjs/relay-examples/tree/master/todo

That project's using graphql@0.13.2 btw.

@kguller

This comment has been minimized.

Copy link

kguller commented Apr 27, 2018

@kassens thanks for that check. I was using graphql 12.0, which I thought was supported. I did an update to 13.2 and got past this issue. The todo project tested through just fine.

Fix

Update graphql lib to 13.2 from 12.0 or lower.

@kguller kguller closed this Apr 27, 2018

@kassens

This comment has been minimized.

Copy link
Member

kassens commented Apr 28, 2018

Looks like we broke compatibility with graphql 0.12.x somewhere which is listed as acceptable in the peer dependency. Sending a PR to propose removing 0.12.x support.

@Auchindoun

This comment has been minimized.

Copy link

Auchindoun commented May 15, 2018

I am getting this error as well after updating to 1.6, however I don't have Graphql installed as a node module. We have our backend written in Go. We are using the latest for that as well:

[[constraint]]
  name = "github.com/graphql-go/graphql"
  version = "0.7.5"

Should I revert my packages for Relay or am I doing something wrong?

@sibelius

This comment has been minimized.

Copy link
Collaborator

sibelius commented May 15, 2018

yarn add graphql in your relay project should fix this

@Auchindoun

This comment has been minimized.

Copy link

Auchindoun commented May 15, 2018

Hmm.. That changed the error to:

Expected undefined to be a GraphQL leaf type. error An unexpected error occurred: "Command failed.
Exit code: 100
Command: sh
Arguments: -c relay-compiler --src ./app --schema ./schema.graphql
Directory: xxx
Output:
".

Our code has been working pre 1.6 (we have been using 1.3 in production), so I'm not sure why this error would appear with no context. The docs didn't look to have any breaking changes relevant to us. Do you have any insight you can give @sibelius?

@kassens

This comment has been minimized.

Copy link
Member

kassens commented May 16, 2018

@Auchindoun I think you might be using graphql 12.x, could you check and upgrade to 0.13.x?

@Auchindoun

This comment has been minimized.

Copy link

Auchindoun commented May 17, 2018

@kassens Yep, running react 16.3.2, graphql 0.13.2, react-relay 1.6.0, and relay-compiler 1.6.0

@okbel

This comment has been minimized.

Copy link

okbel commented Sep 1, 2018

Confirming: graphql14.0 does not work. Locking on 0.13.2 -

TL;DR > run yarn add graphql@0.13.2

@jstejada

This comment has been minimized.

Copy link
Contributor

jstejada commented Sep 9, 2018

@okbel are you seeing the same error as above with graphql 14.0?

@Pyrrh

This comment has been minimized.

Copy link

Pyrrh commented Oct 13, 2018

I got the same error with graphql 0.14.0 -- reverting to 0.13.2 seems to have resolved it.

fletcher91 added a commit to fletcher91/mady that referenced this issue Oct 27, 2018

Upgrade graphql-linked dependencies
Fixes a build issue where `rule` was not a function
see facebook/relay#2428

@fletcher91 fletcher91 referenced this issue Oct 27, 2018

Open

Git builds #21

fletcher91 added a commit to fletcher91/mady that referenced this issue Nov 8, 2018

Upgrade graphql-linked dependencies
Fixes a build issue where `rule` was not a function
see facebook/relay#2428
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment