-
Notifications
You must be signed in to change notification settings - Fork 2k
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
add validation of directives in SDL #1389
Comments
Currently working on a PR for this issue. I am going to make it more strict, for now. So we will validate all of:
My plan is to add this within the |
I'm also working on it for a couple of weeks and I tried a few different approaches. Currently, I'm working on creating
A few benefits:
@mjmahone What do you think about this aproach? |
@IvanGoncharov that sounds like you're further along than me. I want basically everything you described, but I am willing to take a shortcut and just extend On thing is that I really want to have us push |
Can you wait until monday morning your time? |
Yup I will wait. I would much rather have validation that can be run on the SDL AST than on an already-created schema, and like that this validation would mirror what we already do with @IvanGoncharov if there's a branch I could work on top of, or if you want me to create that branch, I might be able to add more validation, or move more validation from validateSchema to individual SDL validation rules. |
I'm trying to figure out if it's possible to reuse the same context for buildSchema and extendSchema since they are totally different use cases so I'm mostly figuring API for ValidationContext. I will reuse tests from your PR and I will try to push WIP PR after I have stable API to get feedback from you. |
@mjmahone Update: I finally figured out how to solve the last major problem. |
@IvanGoncharov is there more SDL validation you think we need prior to the 14.0 release? If so, anything I can do to help push it forward? I'd like us to put up at least an RC release by Monday if possible. |
@mjmahone Sorry for the silence. I'm working on a PR that will add a few more rules.
Monday seems reasonable due date for RC release 👍 |
@IvanGoncharov not sure what other validations you have in mind. But validating input types on Directive args would be nice. Down to help with this if needed. Thanks for the hard work. 💯 |
@IvanGoncharov I think with #1463, this release is ready for at least a public RC? If so, I can put up a PR to bump the version tomorrow. I should also be able to do the upgrade across Relay's packages as well, although we might wait to actually bump the Relay version (@kassens would know that process better than me). |
@Hendrixer You absolutely right, we still don't validate directives fully since this rule doesn't support SDL: But I think it less important and we could add this support later minor release.
It would be great if you try current master: graphql-js/src/utilities/__tests__/extendSchema-test.js Lines 1292 to 1303 in 4631744
@mjmahone In the last few weeks, I also discover a couple of pretty small issues that technically a breaking change. They all about removing a few obscure features so I will try to make PRs in a next few hours. |
Is this feature still being considered? I ask because it's mentioned in ardatan/graphql-tools#920. It's hard to trust/rely on directives when a graphql server can be started without directive functions and the directives in the SDL get skipped over/ignored. |
I believe directive usage is validated now. Your issue over at graphql-tools ardatan/graphql-tools#920 (comment) suggests that you have a slightly different ask, see my response over there |
Well, validated in a sense that the directives have to exist, I don't know if the arguments are validated / coerced yet... |
Thanks for the help, all I want is to ensure that the directive functions exist, although yes I believe that the original author of the issue on graphql-tools wants to verify that the implementation is also correct. I've been trying this with 15.3.0 and 14.5.8 and finding that the directive functions don't have to exist, but I'll give it another go. |
Any updates on validating the argument types? https://spec.graphql.org/October2021/#sec-Values-of-Correct-Type seems to suggest that all literals should be validated, not just in executable. Shall we extend ValuesOfCorrectTypeRule.ts to SDL? |
From #1383:
The text was updated successfully, but these errors were encountered: