Feature Request: add build time transformations to useStaticQuery #34198
Unanswered
khinshankhan
asked this question in
Ideas / Feature Requests
Replies: 1 comment 3 replies
-
Does GraphQL is by design made to get optimized and view-based datas. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
This is an enhancement to the
useStaticQuery
hook. According to this https://www.gatsbyjs.com/docs/static-vs-normal-queries/ the queries results are saved into json files. I think it'd be neat and doable to pass in transformations to the hook, egThis is a rather simplified example, there are definitely much more complex uses of this, but the benefit is that now these transformations occur at build time rather than during each user request.
Data transformations could make data easier to deal with but the real benefit I see it they can also change the data for different types of access that a raw query may not be able to readily support. Eg if an array there's an array of tags/ categories, developers may want constant lookup for them. A good way would be to use a set or map structure, but graphql doesn't support readily those data types, especially since every field must be specified. An array would be the best type for the query, but a data transformation could make it so
["a", "b"]
=>{a: true, b: true}
, providing the constant lookup.Beta Was this translation helpful? Give feedback.
All reactions