-
-
Notifications
You must be signed in to change notification settings - Fork 105
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
Support filtering based on child table relationship #88
Comments
This issue is stale because it has been open for 30 days with no activity. |
Would like to see this as well, this is really what makes graphql appealing imo. |
How can I vote for this enhancement? 😅 |
you just did! I agree this would be a great feature. We're currently focusing on some rough edges where we're not quite spec compliant + and improving type support (json/jsonb) arrays etc. Once we have a good foundation for all the basics, this will be a feature we'll be interested in, but it isn't actively under development yet |
+1 (Adding context from #296) Hasura can do this for both child and parent relationships. AFAIK the REST API can do this currently only for child relationships (see "Filter Foreign Tables"). For example with Hasura, this selects authors containing a name with all their books, or authors and the specific books whose description contains the name. This is often desired in a search. Note how this filters both on child and parent relationships. query {
authors(where: {_or: [{name: {_iregex: $name}}, {books: {description: {_iregex: $name}}}]}) {
name
books(where: {_or: [{author: {name: {_iregex: $name}}}, {description: {_iregex: $name}}]}) {
title
description
}
}
} (Note, for the relationship names to be set like this in Hasura, the foreign key columns should not match the table name. For example, one can use a suffix like |
Any update on this feature? It's currently my biggest blocker. |
No movement yet but I'm aware that this is high interest feature The only higher priority is user defined mutations via SQL functions FYI: |
I just wanted to add to the hype of this feature 🥳. Keep up the good work pg_graphql is very promising! |
I'm also looking for this feature! |
Interested in this one. Is there any workaround now like database views or whatever? |
unfortunately, there isn't currently a workaround for filtering parents based on children |
none yet, but we've identified nested inserts (which requires upsert support to work well) as the next big project we're tackling in pg_graphql so you should start to see movement on it |
is there any workaround to achieve the same effect right now? |
You could
but all have their drawbacks |
I'm trying to filter data from table A based on a value in table B. Specifically, I want to filter records where B.something (some condition) specific value. I haven't been able to find an example of this query in the Supabase documentation. Could you please confirm if this type of filtering is supported in GraphQL on Supabase? If not, are there any workarounds or alternative approaches I could consider? |
@Mihai-github have you tried one of the options mentioned by @olirice above? If these don't work for you can you share more details about your use case? |
I'd love to tackle this problem, but I'm not sure how the GQL is translated into a PG query. Is the GQL just translated into a pgREST query? |
No, GQL is converted into a SQL query which is executed by the
The Let me know if this is sufficient detail for you to take a stab at implementing a solution or you need more. |
We have any update on this?
Do you have a preferred method of these 3? |
My preferred option would be #1 |
So, I've managed to get a function that I can query successfully in the SQL Editor but it does not show up in my GraphiQL playground. Any suggestions? I left out 'immutable' and 'stable' as I've tried both to no avail.
Looks like I finally got it working! Thanks for the direction! |
Hi @olirice, any progress on this? Thanks ;) |
not yet. we're currently working on upsert |
Describe the bug
Support filtering based on child table relationship
Expected behavior
The text was updated successfully, but these errors were encountered: