-
Notifications
You must be signed in to change notification settings - Fork 999
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
Filtering on the basis of child entities #2960
Comments
From https://www.apollographql.com/docs/apollo-server/schema/unions-interfaces/#union-type:
So that means we can't support both
and
at the same time. 😢 |
Yeah, because union and interfaces need to be resolved using So ideally, we can introduce a new form of generating field arguments, that is more flexible and takes child entities into consideration, and gradually deprecate the existing one? |
I guess it depends on how the data is fetched. All these filters could be applied as one or as many depending on the data fetching implementation. If some of them are super heavy for the database, we could define a score for them and calculate the complexity/heaviness of the query (score of 1200, where the limit is 250 will block the query from running).
I'm not sure what do you mean here.
All the arguments defined within an interface has to be defined in types implementing this interface, no extra arguments in these types. https://stackblitz.com/edit/typescript-mjzhzw
Exactly what Dotan and Jannis said. |
What @azf20 meant was that for any interface defined in the subgraph's GraphQL schema, the generated GraphQL API will have fields such as I think the answer is fairly straight-forward: we should only generate child filter arguments for the fields in the interface, not in the concrete types that implement it. |
Given:
If I query for:
Presumably I get authors where |
As discussed yesterday:
Though this might be a bit opaque / not "graphQL-y", so open to suggestions. Other ideas:
I think this does highlight the need to (at some point) release a v2 with breaking changes. |
Sounds good, we can start with that and see how it looks like. Other suggestions are totally valid as well.
Makes a lot of sense, it's a good thing that we tackle some of these now, it will be easier to plan v2 of the GraphQL API. |
We could start with supporting only the form |
That is interesting, though won't that lead to quite explosive Filter types? |
That's a good point. Ok, I guess I don't mind the trailing |
I hope I am getting the gist of this issue, if so, it also depends in how your data is structured. In this query, I am applying a filter to a child entity. Again, it depends if your data model supports this. The Graph also offers you the ability to create your own graphs where I'm sure you could massage the model to your liking:
|
Super excited for this update! Thank you all for working on this feature. Do you all know when this will be live for us to use? And does this update include sorting as well, or just filtering? |
Hi @mihoward21 this is currently in testing, will ping this thread! The initial feature is just filtering, with sorting to come (follow #3737 for more!) |
Subgraph consumers can currently only filter and sort on the basis of top-level entity fields. As a consumer, I want to be able to filter and sort on the basis of child entity fields.
Schema:
Query:
userProfile: "12345"
and the nested filter? Will need to be a union of a String and an object, or make a breaking changeMeta-task: compare with syntax from other projects
The text was updated successfully, but these errors were encountered: