-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Union input types #202
Comments
You are probably aware of graphql/graphql-js#207 already. As you say, this is probably mostly useful for generic backends, but I hope more compelling use cases will emerge so we can convince Lee that the utility outweighs the added complexity. |
Continuing from #215 @IvanGoncharovIvan offered a solution that looks to this problem:
It looks like this: filtering: {
clicks: {
LESS_THAN: 42
},
campaign_id: {
IN: ["1", "2"]
}
}
This would work well in many cases, however, in this particular case, you end up having |
Just opened #395 as an RFC to potentially address this need. |
Closing in favor of #395 |
Could we make union types of strictly input types an input type? Often I find places where having a union type as the argument to a GraphQL field could be useful. Especially for complex querying. For example an
orderBy
field could take a single ordering enum or an array of enums:orderBy: ID
ororderBy: [FIRST_NAME, ID]
with union input types.Another example could be complex conditions. So for instance we could have the following (rough) type definition:
Where here say the literal
Int
would be the same as anIntOperation
with an operator ofEQUALS
. And the array ofStringOperation
could be joined together with ands when querying the database.I don’t think union input types are useful for people who are handcrafting their schemas (although it may be), but union input types are incredibly useful for GraphQL as a service type products. That provide the user with a GraphQL schema and then allow that user to perform arbitrary queries against that schema. And here I don’t mean “arbitrary queries” in the sense that GraphQL allows the client to define the exact data it wants from the schema, but rather arbitrary queries to the backend. Whether that backend be a SQL database, NoSQL database, or something proprietary.
The text was updated successfully, but these errors were encountered: