4 releases
new 0.0.4 | Feb 6, 2025 |
---|---|
0.0.3 | Feb 3, 2025 |
0.0.2 | Jan 29, 2025 |
0.0.1 | Jan 28, 2025 |
#84 in #results
503 downloads per month
Used in 4 crates
(via sui-gql-client)
13KB
228 lines
Macro to extract data from deeply nested types representing GraphQL results
Suggested workflow
- Generate query types using cynic and its generator
- Use insta to define an inline snapshot test so that the query string is visible in the module that defines the query types
- Define an
extract
function that takes the root query type and returns the data of interest - Inside
extract
, useextract!
asextract!(data => { ... })
- Inside the curly braces, past the query string from the snapshot test above
- Change all node names from
camelCase
tosnake_case
- Add
?
after the nodes that are nullable - Add
[]
after the nodes that are iterable
lib.rs
:
Macro to extract data from deeply nested types representing GraphQL results
Suggested workflow
- Generate query types using cynic and its generator
- Use insta to define an inline snapshot test so that the query string is visible in the module that defines the query types
- Define an
extract
function that takes the root query type and returns the data of interest - Inside
extract
, useextract!
asextract!(data => { ... })
- Inside the curly braces, past the query string from the snapshot test above
- Change all node names from
camelCase
tosnake_case
- Add
?
after the nodes that are nullable - Add
[]
after the nodes that are iterable
Dependencies
~215–660KB
~16K SLoC