graphback icon indicating copy to clipboard operation
graphback copied to clipboard

Filtering across relationships

Open lastmjs opened this issue 4 years ago • 6 comments

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

lastmjs avatar May 29 '20 21:05 lastmjs

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)

wtrocki avatar May 31 '20 11:05 wtrocki

Actually we do not support bidirectional filtering now. See: https://github.com/aerogear/graphback/issues/1338

wtrocki avatar May 31 '20 14:05 wtrocki

Also, there is no support for filtering across many to many relationships as far as I can tell

lastmjs avatar Jun 08 '20 17:06 lastmjs

@wtrocki @machi1990 are we looking to get this in before or after 0.14.0?

craicoverflow avatar Jun 23 '20 08:06 craicoverflow

Looks like after. I really hope to get this soon, very foundational requirement IMO

lastmjs avatar Jul 24 '20 20:07 lastmjs

Thanks for bumping this @lastmjs , added a triage label and we'll prioritise this over the coming weeks.

machi1990 avatar Jul 24 '20 21:07 machi1990