-
-
Notifications
You must be signed in to change notification settings - Fork 249
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
Schema validation: interfaces #229 #243
Schema validation: interfaces #229 #243
Conversation
ef4c199
to
19122af
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TobiasPfeifer looks good so far!
@ghostdogpr I've implemented fieldname and argumentname validation. I'm now thinking about return type and input type validation. Should I try to lift this validation to the type level? A That way However it's possible for me to leave the types as they are and validate on them at runtime |
@TobiasPfeifer doing it at the type level would be better in the general case, however |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more thing I told to @zach-albia who's working on #228:
Enum and union were very simple and didn't really need unit tests (and I think Caliban by default can only generate valid ones) but here rules are more complex so I think it would be good to have some. The existing tests in ValidationSpec are all about query validation, so yours will be a bit different: you'll need to create a GraphQL object, and check if .interpreter
returns the appropriate ValidationError
.
@ghostdogpr Something came up so I haven't gotten around to pushing a WIP PR #228 yet. Looking to get back to it this Saturday. |
@zach-albia no problem. There are a few rules in common in your 2 issues (and the one @mriceron is doing too) so keep an eye on the other PRs. Whoever does it first, the others can reuse 😄 |
@ghostdogpr I'll add tests to ensure correct ValidationError when calling
Sure. I'll implement runtime validation with this PR. If I feel challenged to find a way to do this on the type level without altering the |
#244 was merged so you can re-use the same file for tests (and maybe some of the code) |
…idation_Interfaces # Conflicts: # core/src/main/scala/caliban/validation/Validator.scala
fccd277
to
be11dc4
Compare
c5356c4
to
2f25426
Compare
@ghostdogpr I restructured my code to match the structure of #244 and reused common validation methods Regarding the tests: I think it's not possible to construct an |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Just a few remarks to get better error messages and we can merge 👍
core/src/test/scala/caliban/validation/ValidationSchemaSpec.scala
Outdated
Show resolved
Hide resolved
core/src/test/scala/caliban/validation/ValidationSchemaSpec.scala
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All good! Thanks for contributing!
initial schema validation method layout for interfaces for #229
@ghostdogpr can you do an early stage review of
private def validateInterface(t: __Type)