- Docs
- API reference
- Endpoints and schemas
- GraphQL
- Directives
@join
Joins array elements into a single string using the 'sep' separator (defaults to empty string).
Directives. This directive runs after the query has its answer. It changes what you see, not what the query reads.
Joins array elements into a single string using the ‘sep’ separator (defaults to empty string). Null values become empty strings. Non-string values (integers etc) are stringified. Example: _fn @join(refs: [“a”, “b”], sep: “, “) returns “val_a, val_b”.
Arguments
Section titled “Arguments”| Argument | Type | Description |
|---|---|---|
ref |
String |
A dot path to one value in the response, relative to the object that holds _fn. Each segment is a field name or alias, a list index, or * for every item of a list. Write ref or refs as the first argument of the directive. |
refs |
[String!] |
A list of dot paths, written as for ref. The directive takes the list of their values as its input. In a chain of directives, only the first directive reads ref or refs, and each later directive takes the output of the one before it. |
sep |
String |
The text to put between items. If you omit it, the directive joins the items with no text between them. |
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 cities: _fn @map(refs: ["operatingLocations"], field: "edges.*.node.addresses.edges.0.node.city") @join(sep: ", ") operatingLocations(first: 3) { edges { node { addresses(first: 1) { edges { node { city } } } } } } } }}Response, as returned:
{ "data": { "search": [ { "id": "0f26fbef-3436-4f85-8bcd-31fe12a4f99a", "cities": "BEND, PRINCE FREDERICK, DELTA", "operatingLocations": { "edges": [ { "node": { "addresses": { "edges": [ { "node": { "city": "BEND" } } ] } } }, { "node": { "addresses": { "edges": [ { "node": { "city": "PRINCE FREDERICK" } } ] } } }, { "node": { "addresses": { "edges": [ { "node": { …}