We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
path
Given a query for a list of objects:
query { something { items(limit: 1) { name } } }
And we want to normalize an Item to the index by which it appears in items.
Item
items
normalization: { identifier(item) { return item.__typename + index } }
One possible way of implementing it, is a second getParent / path argument:
getParent
normalization: { identifier(item, { getParent, path }) { // path == [ { key: "0", args: null, data: { name: "" } }, { key: "items", args: { limit: 1 }, data: [{ name: "" }] }, { key: "something", args: null, data: { items: [{ name: "" }] } }, { key: null, args: null, data: { something: { items: [{ name: "" }] } } }, ]; const { key, args, parent } = getParent(item) // key == "0" // args == null // parent == [{name:""}] return item.__typename + key // aka the index } }
path being an array of the keys / args / data to the root of the response
and getParent being a function which accepts any item, and returns the key/args of the item, along with the parent item (which can be fed back in)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Given a query for a list of objects:
And we want to normalize an
Item
to the index by which it appears initems
.One possible way of implementing it, is a second
getParent
/path
argument:path
being an array of the keys / args / data to the root of the responseand
getParent
being a function which accepts any item, and returns the key/args of the item, along with the parent item (which can be fed back in)The text was updated successfully, but these errors were encountered: