graphql/execution/paths

Functions

responsePathAsArray()

Given a Path, return an Array of the path keys.

Signature:

responsePathAsArray(path: null | undefined | Readonly<Path>): (string | number)[]

Arguments

NameTypeDescription
pathnull | undefined | Readonly<Path>The linked response path to flatten.

Returns

TypeDescription
(string | number)[]An array of response path keys from root to leaf.

Example

import { pathToArray } from 'graphql/execution';
 
const result = pathToArray(path);
 
// result contains the pathToArray return value