Hi! I have a tags: [String!]! field in my model. H...
# prisma-whats-new
m
Hi! I have a tags: [String!]! field in my model. However, there's nothing (such as "tags_contains" or even plain "tags") generated in the filter for this fields (all other fields work)
n
@mikko hey, we don't feature filters for scalar lists as in your case yet. A possible workaround is promoting the string field to a model that contains a string field
m
Thanks for the response. Do you have an example somewhere of how to achieve the promoting to the model?
Also, do you have an estimate when lists will possibly be supported in filters?
n
Can you tell me more about the model and the tags field?
We're aware of this feature request: https://github.com/graphcool/feature-requests/issues/60 I cannot comment on any ETA though, sorry! 🙂
m
A very typical model of a Post that has Tags associated with it, like in a blog
Then I'd like to filter all Posts that have for example Tag "food" present in it's Tag [String] field
n
I see! In this case you can instead create a new model
Tag
with the field
key: String
then you have a many-to-many relation between
Post
and
Tag
Copy code
query {
  allPosts(filter: {
    tags_some: {
      key: "TRAVEL"
    }
  }) {
    id
  }
}
this would be a query for all travel posts 🙂
m
That works, thanks! Any thoughts on best practices when creating a new post with multiple tags: should I check for existing tags and create new ones for ones that don't yet exist or try to create them all and see which ones bounce since the key field is Unique?
n
I think only creating new ones works best