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

ValuesOfCorrectTypeRule missing in specifiedSDLRules #3222

Open
Yogu opened this issue Aug 3, 2021 · 1 comment
Open

ValuesOfCorrectTypeRule missing in specifiedSDLRules #3222

Yogu opened this issue Aug 3, 2021 · 1 comment

Comments

@Yogu
Copy link
Contributor

Yogu commented Aug 3, 2021

specifiedSDLRules, which is used in buildASTSchema, does not include the ValuesOfCorrectTypeRule validation rule. I think this rule is needed to e.g. reject true where an object literal would be expected on a directive argument.

@Yogu Yogu changed the title ValuesOfCorrectTypeRule missing in specifiedSDLRules ValuesOfCorrectTypeRule missing in specifiedSDLRules Aug 3, 2021
@IvanGoncharov
Copy link
Member

@Yogu Thanks for pointing this out 👍

The problem here is that ValuesOfCorrectTypeRule requires a full schema with all types in it and during SDL validation we have only AST.
The correct solution would be to build schema (with error recovery) first and only then use it for validation.
For example here is how TS deal with such issue:
https://www.typescriptlang.org/play?#code/C4TwDgpgBAYg9nKBeKBvAUFKBDA-ALigGVgAnASwDsBzTKAIwKgCF0BfddAMwFdKBjYOTiUoXABRcEheHACUaDt3GochAEQBWdWznLV9Ddt1QA9KagBJapTikIAZzHkIAGwAmUOFyh8A1rYA7qKgkJwSqtiEmrr6UPzRukA

image

So coding error recovery for buildASTSchema is not as simple as it looks we can't just ignore invalid fields (otherwise we will generate errors for every place where this field is used) we need to figure out a way to have "InvalidType" object of some kind.

TLDR It's something we need to fix but it requires big changes in how buildASTSchema works.

@IvanGoncharov IvanGoncharov added this to the post-16.0.0 milestone Aug 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants