Skip to content
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

Include fields for GraphQLError #273

Closed
wants to merge 2 commits into from
Closed

Include fields for GraphQLError #273

wants to merge 2 commits into from

Conversation

CatTail
Copy link

@CatTail CatTail commented Jan 7, 2016

Possible fix #192

@@ -353,6 +354,7 @@ function collectFields(
if (!fields[name]) {
fields[name] = [];
}
selection.parentField = parentField;
Copy link
Contributor

Choose a reason for hiding this comment

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

We want to ensure that we're not mutating the provided AST, as it may be used elsewhere.

@leebyron
Copy link
Contributor

leebyron commented Jan 9, 2016

Thanks so much for investigating this!

We should be careful not to mutate inputs but also careful to ensure the performance of query execution is not negatively impacted. One case I imagine would not work correctly here is if a query includes the same fragment in two locations, an error occurring in both locations. The parentField property would have been overridden by the second call, and the first error would have an incorrect execution path.

@CatTail
Copy link
Author

CatTail commented Jan 11, 2016

Add unittest for

One case I imagine would not work correctly here is if a query includes the same fragment in two locations, an error occurring in both locations.

Maybe I have misunderstanding?

And the problem of add parentField for AST, can you provide a better way to retain parent field information without modification of AST?

@CatTail
Copy link
Author

CatTail commented Feb 1, 2016

ping @leebyron

@leebyron
Copy link
Contributor

leebyron commented Feb 2, 2016

For example:

fragment X on T {
  x
}

query {
  a { ...X }
  b { ...X }
}

Where the field x throws an error.

Currently by my understanding of your code, this will result in printing out two errors, where both errors will report b.x even though the first should report a.x - this occurs because of the mutation of the field nodes, and the fragment being used in more than one location.

At the very least, this test should be included so that this is known not to occur.

My opinion on how to maintain the execution path is to maintain this as an additional "Stack" variable provided during execution, rather than mutating the AST provided to the execution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Name of a field inside errors:{locations:[]}
3 participants