Skip to content

Write util for GraphQL data manipulation to deal with edges and nodes

As we keep implementing GraphQL API endpoints on the frontend, we keep encountering the same requirement to manipulate data to un-nest edges and nodes to make data structure simpler to be consumed. We should write a util that would make it easier for us to repeat across the code base.

Example use case:

return epics.map(e => ({
  ...e,
  issues: (e?.issues?.nodes || []).map(i => ({
    ...i,
    labels: (i.labels?.nodes || []),
    assignees: (i.assignees?.nodes || []),
  })),
}));

cc @psimyn

Edited by Florie Guibert