- Docs
- API reference
- Endpoints and schemas
- GraphQL
- Directives
@skipEmpty
Prunes nodes from a connection when the nested connection at the 'field' dot-path has no edges, recursing upward: a node left with no edges is pruned from its parent too, until a level with a non-empty sibling.
Directives. This directive runs after the query has its answer. It changes what you see, not what the query reads.
Prunes nodes from a connection when the nested connection at the ‘field’ dot-path has no edges, recursing upward: a node left with no edges is pruned from its parent too, until a level with a non-empty sibling. Applied on the connection field itself. Example: legalEntities @skipEmpty(field: “registeredEntities.registrations.roles.edges”) drops registrations whose roles are empty, then registered entities and legal entities left with nothing beneath them.
Arguments
Section titled “Arguments”| Argument | Type | Description |
|---|---|---|
field |
String! |
A dot path from each node of this connection to a nested connection, written with field names or aliases. The directive removes each node whose nested connection has no edges, then each parent that the removal leaves empty. A final edges segment is optional. |
Where it goes
Section titled “Where it goes”FIELD.
Example
Section titled “Example”query { search(searchInput: { entityType: BRAND name: "Safeway" conditions: { limit: 1 } }) { ... on Brand { id operatingLocations(first: 3) @skipEmpty(field: "phoneNumbers") { edges { node { id phoneNumbers(first: 1) { edges { node { phoneNumber } } } } } } } }}Response, as returned:
{ "data": { "search": [ { "id": "0f26fbef-3436-4f85-8bcd-31fe12a4f99a", "operatingLocations": { "edges": [ { "node": { "id": "c458c91f-907c-4ec1-bbe1-e9b39baee074", "phoneNumbers": { "edges": [ { "node": { "phoneNumber": "+19252265000" } } ] } } }, { "node": { "id": "4f378c48-16b0-4a38-8b1f-c1005a2da1cd", "phoneNumbers": { "edges": [ { "node": { "phoneNumber": "+12063633130" } } ] } } }, { "node": { "id": "8d41aec8-aec8-4d3d-b7b4-84e81b53d45a", "phoneNumbers": { "edges": [ …}