caliban
caliban copied to clipboard
Add support for `@oneOf` inputs
VERY early draft for adding support for the @oneOf inputs, just to discuss whether we're on the right track. See current version of the RFC here
Some of the assumptions I made:
- We probably want to require an annotation to mark an input sealed trait as a
oneOf. I think that makes sense since the spec on@oneOfis very strict, so it's very unlikely that these sealed traits will be used for any return types - Since in Scala 3 we control derivation, I enforced the checks that the sealed trait is a valid
@oneOfvia macros. I think it's nicer UX if we give compile-time errors instead of runtime ones for invalid types. However, in Scala 2 we don't control the derivation so we have to enforce these checks during runtime. I understand if we want to unify the validation, so I'm happy to remove the macros - I couldn't find anything in the spec (might have missed it though) but I assumed we don't want to mark inputs as
@oneOfif they have only 1 field (kind of defeats the purpose?)
TODO:
- [x] Add validations for
@oneOfinputs inValidator(both against the Schema & user inputs) - [x] Add tests where
@oneOfinputs are a mix of input objects and Scalars - [ ] Add documentation
- [ ] Discuss on what we should do with the client