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

Invariant Violation: RelayQueryField() in todo example #408

Closed
reginedanica opened this Issue Oct 1, 2015 · 9 comments

Comments

Projects
None yet
7 participants
@reginedanica

I tried to remove items in the todo list and I got this error

'Uncaught Error: Invariant Violation: RelayQueryField(): Expected field id to be annotated with the type of the parent field.'

@wincent

This comment has been minimized.

Show comment
Hide comment
@wincent

wincent Oct 1, 2015

Contributor

Thanks for the report, @reginedanica. What version of the code are you running? I can't repro this on the current HEAD of master.

Maybe you are running an old version of the babel-relay-plugin. Try running npm install && npm run update-schema && npm run start in the todo example and see if you can repro.

Contributor

wincent commented Oct 1, 2015

Thanks for the report, @reginedanica. What version of the code are you running? I can't repro this on the current HEAD of master.

Maybe you are running an old version of the babel-relay-plugin. Try running npm install && npm run update-schema && npm run start in the todo example and see if you can repro.

wincent added a commit to wincent/relay that referenced this issue Oct 1, 2015

Don't require babel to be installed globally
While investigating an issue reported for the todomvc example
(facebook#408), I tried to repro as
follows:

```
git checkout master
git fetch upstream
git merge upstream/master
npm install && npm run update-schema && npm run start
```

But it went boom during the `npm install` because I didn't have `babel`
installed globally:

```
sh: babel: command not found
```

(Full output at https://gist.github.com/wincent/3221694ee3fdc46084f4)

What's happening here:

- example's `preinstall` tries to run `install` from the top-level
- top-level `install` tries to install babel-relay-plugin dependency
- babel-relay-plugin `build` step runs and tries to shell out to `babel`
- `babel` call will blow up if not globally installed, even though babel
  is listed as a dev dependency

Workaround:

```
npm install -g babel
```

Fix employed here: we add `npm install --ignore-scripts` to the
babel-relay-plugin `build` recipe, causing it to become available in
`node_modules` and therefore the `$PATH` when the `babel` command later
runs. Note that without the `--ignore-scripts` we get into an infinite
loop, although I am not sure of the exact chain of cause and effect
because all we see on the console at that point is this, endlessly
repeated:

```
> babel-relay-plugin@0.2.6 build /Users/glh/code/relay/scripts/babel-relay-plugin
> rm -rf lib; npm install; npm run babel
```

Also note the use of `;` instead of `&&` in the interest of preserving
potential future compatibility with Windows.

I think this change should be ok for end users or the
babel-relay-plugin, as they don't end up running the `build` script and
instead just get whatever we built into `lib/`.

Test Plan: Blow away global babel (`npm uninstall -g babel`) and example
`node_modules` and then `npm install` from inside example or top-level,
see it no longer blows from.
@zigomir

This comment has been minimized.

Show comment
Hide comment
@zigomir

zigomir Oct 1, 2015

@wincent I have same problem. I'm running 1844dc9 atm.
Running npm run update-schema will fill few description fields inside schema.json.

zigomir commented Oct 1, 2015

@wincent I have same problem. I'm running 1844dc9 atm.
Running npm run update-schema will fill few description fields inside schema.json.

@N0hbdy

This comment has been minimized.

Show comment
Hide comment
@N0hbdy

N0hbdy Oct 2, 2015

Also, at fe3e78f I'm unable to add a new todo, probably for the same reason?

Full error message:
Uncaught Error: Invariant Violation: RelayQueryField(): Expected fieldidto be annotated with the type of the parent field.

N0hbdy commented Oct 2, 2015

Also, at fe3e78f I'm unable to add a new todo, probably for the same reason?

Full error message:
Uncaught Error: Invariant Violation: RelayQueryField(): Expected fieldidto be annotated with the type of the parent field.

@pcarion

This comment has been minimized.

Show comment
Hide comment
@pcarion

pcarion Oct 2, 2015

i have also this same error on the current HEAD - I did run:

npm install && npm run update-schema && npm run start

The error is due to an invariant at:
https://github.com/facebook/relay/blob/master/src/query/RelayQuery.js#L890

under debugger, it appears that
this.__concreteNode__ is:

GraphQLFieldNode {
  kind: "Field", 
__proto__: GraphQLFieldNode,
  fieldName: "id"…}

but this.__concreteNode__.metadata is:

edgesID: undefined
inferredPrimaryKey: undefined
inferredRootCallName: undefined
isConnection: false
isFindable: false
isGenerated: false
isPlural: false
isRequisite: false
isUnionOrInterface: false
parentType: undefined

and so that fails the invariant in:

getParentType(): string {
    var parentType = this.__concreteNode__.metadata.parentType;
    invariant(
      parentType,
      'RelayQueryField(): Expected field `%s` to be annotated with the ' +
      'type of the parent field.',
      this.getSchemaName()
    );
    return parentType;
  }

pcarion commented Oct 2, 2015

i have also this same error on the current HEAD - I did run:

npm install && npm run update-schema && npm run start

The error is due to an invariant at:
https://github.com/facebook/relay/blob/master/src/query/RelayQuery.js#L890

under debugger, it appears that
this.__concreteNode__ is:

GraphQLFieldNode {
  kind: "Field", 
__proto__: GraphQLFieldNode,
  fieldName: "id"…}

but this.__concreteNode__.metadata is:

edgesID: undefined
inferredPrimaryKey: undefined
inferredRootCallName: undefined
isConnection: false
isFindable: false
isGenerated: false
isPlural: false
isRequisite: false
isUnionOrInterface: false
parentType: undefined

and so that fails the invariant in:

getParentType(): string {
    var parentType = this.__concreteNode__.metadata.parentType;
    invariant(
      parentType,
      'RelayQueryField(): Expected field `%s` to be annotated with the ' +
      'type of the parent field.',
      this.getSchemaName()
    );
    return parentType;
  }
@steveluscher

This comment has been minimized.

Show comment
Hide comment
@steveluscher

steveluscher Oct 2, 2015

Contributor

Yep! We broke this. @josephsavona is on it!

Contributor

steveluscher commented Oct 2, 2015

Yep! We broke this. @josephsavona is on it!

@josephsavona

This comment has been minimized.

Show comment
Hide comment
@josephsavona

josephsavona Oct 2, 2015

Contributor

Oops! Looking at it.

Contributor

josephsavona commented Oct 2, 2015

Oops! Looking at it.

josephsavona added a commit that referenced this issue Oct 2, 2015

Add parentType for generated mutation `id` fields
Summary: addresses #408
Closes #414

Reviewed By: @steveluscher

Differential Revision: D2503070
@pcarion

This comment has been minimized.

Show comment
Hide comment
@pcarion

pcarion Oct 3, 2015

I can confirm that the TodoMVC app is working now. Thanks!

pcarion commented Oct 3, 2015

I can confirm that the TodoMVC app is working now. Thanks!

@josephsavona

This comment has been minimized.

Show comment
Hide comment
@josephsavona

josephsavona Oct 3, 2015

Contributor

@pcarion thanks for double-checking ;-)

Contributor

josephsavona commented Oct 3, 2015

@pcarion thanks for double-checking ;-)

@reginedanica

This comment has been minimized.

Show comment
Hide comment
@reginedanica

reginedanica Oct 5, 2015

Thanks a lot guys!

Thanks a lot guys!

wincent added a commit to wincent/relay that referenced this issue Oct 13, 2015

Don't require babel to be installed globally
While investigating an issue reported for the todomvc example
(facebook#408), I found that `npm
install` in an example directory was blowing up because I didn't have
`babel` installed globally:

```
sh: babel: command not found
```

(Full output at https://gist.github.com/wincent/3221694ee3fdc46084f4)

What's happening here:

- Example's `preinstall` runs `install` from the top-level.
- Top-level `install` installs its babel-relay-plugin dependency from
  NPM.
- Example's `install` runs, and runs `build` from the babel-relay-plugin
  `file:../` dependency.
- Note that `install` hasn't happened inside the `file:../` dependency
  yet, which means that the `babel` call will blow up if not globally
  installed.

Fix:

- Make sure the example's `preinstall` step `cd`'s into the `file:../`
  dependency and installs its dependencies (ie. `babel`) up front.

Known issue:

- `&&` won't work on Windows. I could "fix" that by using `;` instead,
  but the better fix is to turn these into cross-platform node scripts.
  I'll create a separate issue for that, if I can't find an existing
  one.

Tested: Blow away global babel (`npm uninstall -g babel`), example
`node_modules` and top-level `node_modules`, then `npm install` from
inside an example or top-level; see it no longer blows up. Also `npm run
update-schema` works, as does `npm run start`.

wincent added a commit that referenced this issue Oct 13, 2015

Don't require babel to be installed globally
Summary: While investigating an issue reported for the todomvc example (#408), I found that `npm install` in an example directory was blowing up because I didn't have `babel` installed globally:

```
sh: babel: command not found
```

(Full output at https://gist.github.com/wincent/3221694ee3fdc46084f4)

What's happening here:

- Example's `preinstall` runs `install` from the top-level.
- Top-level `install` installs its babel-relay-plugin dependency from NPM.
- Example's `install` runs, and runs `build` from the babel-relay-plugin `file:../` dependency.
- Note that `install` hasn't happened inside the `file:../` dependency yet, which means that the `babel` call will blow up if not globally installed.

Fix:

- Make sure the example's `preinstall` step `cd`'s into the `file:../` dependency and installs its dependencies (ie. `babel`) up front.

Tested: Blow away global babel (`npm uninstall -g babel`), example `node_modules` and top-level `node_modules`, then `npm install` from inside an example or top-level; see it no longer blows up. Also `npm run update-schema` works, as does `npm run start`.
Closes #409

Reviewed By: @josephsavona

Differential Revision: D2536562

fb-gh-sync-id: fbd5e3c1a8b16747acc219e58fe896f39a32b394
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment