Closed chancharles closed 3 years ago
I am generally in favor of this feature. As the source plugin can be viewed as a standalone package making it more flexible is a great idea. I can approve this change after the following changes/additions have been made:
Thanks a lot for this contribution :-)
Great. Let's discuss the API of this option. Are you okay with this?
fetchOptions: {
post: {
filter: (post) => boolean
},
page: {
filter: (page) => boolean
},
setting: {
map: (setting) => setting
}
}
I would prefer it simpler:
filter: {
posts: (post) => boolean,
pages: (page) => boolean
}
And not support filtering the settings, unless you bring very good reasons for it.
@styxlab Please review the PR again.
I like the idea but I will get a complaint for filter = { posts: (post) => true, pages: (page) => true })
:
'post' is declared but its value is never read.ts(6133)
I like the idea but I will get a complaint for
filter = { posts: (post) => true, pages: (page) => true })
:'post' is declared but its value is never read.ts(6133)
filter = { posts: () => true, pages: () => true })
should do.
Alright. Please review again.
Maybe posts.filter(filter.posts)
is fine, but please make it consistent in all places. With renaming it should look like:
posts.filter(customFilter.posts)
No problem. Please check again.
Looks great! Thanks so much for improving this package 💙
Thanks for your time!
TBH, after reading more code, I think this PR doesn't really fit the intention of this module.
I think it should be the consumer's responsibility to adjust its GraphQL to limit what should is used for the theme. However, this is not easily achievable with the Gatsby GraphQL setup (at least, not with my level of understanding). So, for my immediate need, I am just hacking at the source. Feel free to decline this PR if you find it too hacky.