New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Request: Enable filtering for non array properties contained in an array #4111
Comments
I'm willing to give this a try |
@adam-kuhn couple hints if You want to implement this: Here we add operators to filters in schema:
And here's where actual filtering take place - https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby/src/schema/run-sift.js |
hey... I think this is over my head. So don't expect a solution from me. Thanks for the hints, I'll still attempt to get my head around this, just for the sake of learning |
No problem, thanks for giving it a shot! |
Description
This was previously raised in #1645, allowing for filtering for a property in an array using the example:
@KyleAMathews answered that it is already a feature and showed an example using
tags: { in: [$tag] }
. He is correct, but it only works for properties, like tags, that are arrays. It does not work for properties that are strings. The example above, filtering by id, does not work.It would be great if
in
andnotin
were supported by all property types.FWIW I was able to work around this by adding an
ids
field to the node in onCreateNode that is basically just an array with the one single value of the id of the node. Then it my queries I query forfields: { ids: { in: [$ids] } }
.Actual result
Query throws a graphQL error, syntax is not supported.
Expected behavior
Query should resolve and include any nodes with ids of 123, 456 or 789.
Steps to reproduce
1. Perform a graphQL allThings query with a filter for id existing in an array of strings:
filter: { id: { in: ['123', '456', '789'] } }
The text was updated successfully, but these errors were encountered: