graphback
graphback copied to clipboard
Filtering across relationships
Things have been going very well for me today! I've started to incorporate graphback into a large project to get rid of Prisma.
One significant issue I am facing is a limitation with filtering. Prisma had a way to filter across relationships. This is especially useful when filtering across a one to many relationship.
I have a one-to-many relationship from an entity called Companies, to an entity called Invoices. Each company has many invoices. I want to be able to filter all companies based on fields in the invoices. For example, I would write something like this with Prisma:
query($forMonth: String!) {
companies(
where: {
canceled: false
invoices_some: {
for_month: $forMonth
}
}
) {
id
}
This allows me to get all companies where at least one invoice is in the month I am searching for.
Can graphback support this type of filtering?
Originally posted by @lastmjs in https://github.com/aerogear/graphback/issues/1260#issuecomment-635649893
We have filtering enabled for relationships. https://github.com/aerogear/graphback/blob/master/packages/graphback-codegen-schema/tests/snapshots/GraphQLSchemaCreatorTest.ts.snap#L21
We do not support aggregations - group by etc.(yet)
Actually we do not support bidirectional filtering now. See: https://github.com/aerogear/graphback/issues/1338
Also, there is no support for filtering across many to many relationships as far as I can tell
@wtrocki @machi1990 are we looking to get this in before or after 0.14.0?
Looks like after. I really hope to get this soon, very foundational requirement IMO
Thanks for bumping this @lastmjs , added a triage label and we'll prioritise this over the coming weeks.