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
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.
If someone has scala knowledge and some free time, I believe it requires writing some SQL and updating the files:
https://github.com/graphcool/framework/blob/9d9dd4c76a9519ee72a8a2e5b7be829ec3c24cd3/server/backend-shared/src/main/scala/cool/graph/client/database/QueryArguments.scala
and
https://github.com/graphcool/framework/blob/9d9dd4c76a9519ee72a8a2e5b7be829ec3c24cd3/server/backend-shared/src/main/scala/cool/graph/client/database/FilterArguments.scala
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
Most helpful comment
Adding my voice, this would be really nice to have. More filters is always good!