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

oneof: add test case #4034

Closed
wants to merge 2 commits into from
Closed

Conversation

yaacovCR
Copy link
Contributor

@yaacovCR yaacovCR commented Mar 27, 2024

this test currently passes. should it?

At issue is whether oneof coercion should also check the pre-coerced provided value for the correct number of keys. Currently, it doesn't, although it seems that the proposed spec edits suggests that it should, although the discussion on the issue seems open.

[Similarly, we currently also get an error message of incorrect number of keys if a single misspelled key is provided, in addition to the error about the misspelling, and we don't get an incorrect key if an extra key is given if it is misspelled. All of these stem from the same issue, so graphql-js is currently internally consistent].

@benjie @erikkessler1

links:
graphql/graphql-spec#825
link to discussion on this issue

Copy link

netlify bot commented Mar 27, 2024

Deploy Preview for compassionate-pike-271cb3 ready!

Name Link
🔨 Latest commit bbb82b6
🔍 Latest deploy log https://app.netlify.com/sites/compassionate-pike-271cb3/deploys/66dc9685492a6300089bc719
😎 Deploy Preview https://deploy-preview-4034--compassionate-pike-271cb3.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

Hi @yaacovCR, I'm @github-actions bot happy to help you with this PR 👋

Supported commands

Please post this commands in separate comments and only one per comment:

  • @github-actions run-benchmark - Run benchmark comparing base and merge commits for this PR
  • @github-actions publish-pr-on-npm - Build package from this PR and publish it on NPM

Copy link
Member

@saihaj saihaj left a comment

Choose a reason for hiding this comment

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

I think this should throw an error 🤔 based on All Variable Uses Defined

@benjie
Copy link
Member

benjie commented Apr 3, 2024

The question is kind of moot because the query is meaningless having a variable reference that's not defined; but yes this should fail the "OneOf Input Objects Have Exactly One Field" validation rule:

- Let {fields} be the fields provided by {oneofInputObject}.
- {fields} must contain exactly one entry.

If you define the variable $b, does the issue go away?

@yaacovCR
Copy link
Contributor Author

yaacovCR commented Jun 4, 2024

Have to check back on this

@yaacovCR yaacovCR requested a review from a team as a code owner September 7, 2024 18:08
@yaacovCR
Copy link
Contributor Author

yaacovCR commented Sep 7, 2024

Sorry @saihaj @benjie => I was out of context on this for a while. I updated the operation to include the variable so it doesn't run afoul of "All Variables Used Defined", and the query fails OneOf validation appropriately whether or not the operation variable is included. But it passes execution without a problem, and the question I am asking is if it should throw an error, i.e. whether this invalid query should still execute or not.

I found this discussion, where there seems to have been a request for feedback on this exact issue, without a clear resolution I could find. What the implementation does is let it slide in execution, but from the discussion there it seems like we would have to update the coercion table if that's the choice we make. Not the most live issue, as this is with regards to an invalid query, can certainly wait until after GraphQLConf, hope everyone will enjoy!

@benjie
Copy link
Member

benjie commented Sep 19, 2024

@yaacovCR I believe this is replaced by your newer PRs that mark this as invalid?

@yaacovCR yaacovCR closed this Sep 19, 2024
@yaacovCR yaacovCR deleted the one-of-error-messages branch December 4, 2024 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants