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
Use ancestors as field arguments #144
Comments
It looks like your schema already supports this type of query, which you could write as query {
events {
name
talks {
name
speaker {
name
}
}
}
} |
Interesting! We've been kicking around a similar idea at FB for a while for running two related queries, but doing so within a single query is new. Typically, we try to design our type systems to avoid context-sensitive requests like this in favor of context-free requests. For example, in your first example, you want to know all of the talks at a given event and the speakers for them, excluding talks that are not relevant to the original event. So your query:
should be re-writable as:
In general, the tradeoff we struggle with when considering suggestions like this is if there are compelling use cases that cannot be reasonably solved in other ways that are worth the expense of adding additional complication to GraphQL. While it may not seem like a complicated suggestion, I can already think of a lot of edge cases that could add a ton of complication to the validator and executor. |
@dylanahsmith @leebyron I was thinking about GraphQL as a way to query a data source in the format I want to use on the view. If I have a view that list events, with speakers and then talks, I would prefer to don't transform data on client-side. I opened the issue to see how everyone is handling it. @leebyron Please, evaluate and fell free to close the issue |
@lucaslorentz I have the same request now,and I just see your issue,you are trying to archive this via directive currently,there is no much tools around there,so we my need some adoption for the specified use case. |
@hepin1989
Anyway, there is a need to use data from query results inside the same query. |
@lucaslorentz we at taobao are currently using graphql to build our next generation content platform too,we need some context value to generate the final result. We currently make use of both,but we have not change the syntax but how to fill the $variable. |
For now you have the following options:
Closing it. |
Considering the following schema:
I would like to create queries like:
I checked the specs and didn't find any way to filter the speaker's talks by the ancestor event.
I'm using directives on the examples below to demonstrate a feature GraphQL could have:
That would allow us to completely re-shape the query using the same schema:
Or even go further:
I believe such feature is a nice to have and would decouple even more GraphQL consumers, giving them the ability to completely re-group the data using any entry point: Event, Speaker
Any suggestions/opinions about that?
Related to: #88
The text was updated successfully, but these errors were encountered: