[graphql] Allow filtering children of node too #14060
Replies: 8 comments
-
Hi! That's a good idea. If you want to make a PR, here are some pointers. Children/child fields are added in this function Filter parameters are created in [this function)(https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby/src/schema/schema.js#L476). Filter types are cached, so you can safely call |
Beta Was this translation helpful? Give feedback.
-
+1 for this before it goes stale. I can work around this for now by doing the children filtering when I create the page in |
Beta Was this translation helpful? Give feedback.
-
+1 for this |
Beta Was this translation helpful? Give feedback.
-
Another +1! |
Beta Was this translation helpful? Give feedback.
-
We could really use this too. |
Beta Was this translation helpful? Give feedback.
-
Please refrain from adding "+1" comments, GitHub has the reaction feature for that. Thanks! If you want to contribute to this, please read our documentation here: https://www.gatsbyjs.org/contributing/how-to-contribute/ |
Beta Was this translation helpful? Give feedback.
-
Please add this together with limit and skip on children. Also I think the sort should be available on children, separately, so I can configure sort for every level, instead of only for one field in all levels. Is there any update regarding this? |
Beta Was this translation helpful? Give feedback.
-
Just wondering if there is any update on this? I am building a custom source plugin that requires this functionality. |
Beta Was this translation helpful? Give feedback.
-
Summary
Currently, in Gatsby's GraphQL, it is possible to filter children nodes of top-level "all-instances-of-a-type" fileds like "allFile", "allSite", "allPlugin", etc.
For instance, this works:
What is not possible to do, that should be, is filtering children nodes of other nodes.
Basic example
The below GraphQl request uses
filter
onchildrenFile
. This is not currently possible, ingatsby@2.4.6
.According to @pieh, this feature would have to be implemented inside gatsby core.
Motivation
(M1)
It is a bit confusing that filtering is available on on top-level "all-instances of type" fields, but not on node children. This lead to issue #8764 being raised.
(M2)
On the project I'm working on, I use
createRemoteFileNode
fromgatsby-source-filesystem
to obtain images from github repositories, to use them in pages. The images can the default icon, some other icon, or a screenshot. All are children of the repository, but they'll be used in different component. On of the ideas behind GraphQL is that the response to a query should contain no more than the needed data. This is not possible without filtering(M3) #8764 (comment) (@RIP21)
Beta Was this translation helpful? Give feedback.
All reactions