- Docs
- API reference
- Endpoints and schemas
- GraphQL
- Directives
@trim
Strips leading and trailing whitespace from a string or each string in an array.
Directives. This directive runs after the query has its answer. It changes what you see, not what the query reads.
Strips leading and trailing whitespace from a string or each string in an array. Example: _fn @trim(ref: “name”) trims the value of ‘name’.
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. |
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 name: _fn @trim(refs: ["names.edges.0.node.name"]) names(first: 1) { edges { node { name } } } } }}Response, as returned:
{ "data": { "search": [ { "id": "0f26fbef-3436-4f85-8bcd-31fe12a4f99a", "name": [ "SAFEWAY" ], "names": { "edges": [ { "node": { "name": "SAFEWAY" } } ] } } ] }}