Prisma1: Filters should support scalar lists

Created on 7 Jan 2017  路  17Comments  路  Source: prisma/prisma1

The following filters should be supported for scalar lists:

field_contains: T # contains single scalar T
field_contains_every: [T] # contains all scalar T
field_contains_some: [T] # contains at least 1 scalar T

Most helpful comment

Adding my voice, this would be really nice to have. More filters is always good!

All 17 comments

What about these?

field_not_contains: T # does not contain single scalar T
field_contains_none: [T] # does not contain any scalar T

Good point!

Adding my voice, this would be really nice to have. More filters is always good!

@frederickfogerty does the proposed API cover your use case?

@marktani yep, the simple field_contains is enough to cover our use case

+1 for this

yes please!

this is important for me too:

field_contains: '%somestring%' => similar to LIKE %string% from MySQL filter

Any movement on this guys? Is filtering within an array of values likely to drop anytime soon? Would be particularly helpful to my use-case.

Thanks.

+1

+1

+1

This is necessary for me right now. The only extra thing I would say is to support unique scalar lists for directly querying a node. For example, if I have a schema like
Agent { aliases: [String!] @isUnique }
It would be nice to be able to query directly by any of the aliases in the list.

There is a straight-forward work around as follows:

If you want to filter a list of strings tags: [String!]!:

type Item @model {
  id: ID! @isUnique
  tags: [String!]!
}

you can introduce a new type Tag with a single key: String field and connect Item to Tag one-to-many or many-to-many:

type Item @model {
  id: ID! @isUnique
  tags: [Tag!]! @relation(name: "ItemTags")
}

type Tag {
  id: ID! @model @isUnique
  key: String!
  item: Item @relation(name: "ItemTags")
}

Now you can filter items based on their connected tags using the tags_none, tags_some and tags_every filters:

# query all general items
query {
  allItems(filter: {
    tags_some: {
      key: "general"
    }
  }) {
    id
  }
}

Please use Github reactions instead of short comments.

Thanks for the input everybody!

Please see this proposal for our suggested implementation: https://github.com/graphcool/framework/issues/1275

This feature requires a fundamental change to the data structure for scalar lists, so it would be very valuable to get feedback on the suggested functionality as soon as possible, so we can make sure the new data structure supports all required features.

Fixed link to the issue with the proposal for future visitors: https://github.com/prisma/prisma/issues/1275

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wereHamster picture wereHamster  路  37Comments

mcmar picture mcmar  路  57Comments

Bradly-kunthrope picture Bradly-kunthrope  路  37Comments

sorenbs picture sorenbs  路  43Comments

marktani picture marktani  路  44Comments