FE: Util for GraphQL data manipulation to deal with edges and nodes
requested to merge 226983-write-util-for-graphql-data-manipulation-to-deal-with-edges-and-nodes into master
What does this MR do and why?
Adds util function getNodesOrDefault
for GraphQL data manipulation.
It helps to avoid such construction (which can be met often across the app) const nodes = data?.users?.nodes || [];
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
How to set up and validate locally
This function can be used in one of the following ways:
const nodes = getNodesOrDefault(data?.users);
-
const nodes = getNodesOrDefault(data?.users, 'nodes');
to explicitly set the field name
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #226983 (closed)
Edited by Paul Slaughter