Gato GraphQL logo

Field Response Removal

Field Response Removal

Addition of the @remove directive to the GraphQL schema, which removes the output of a field from the response.

In the query below, we generate the URL to send an HTTP request to, using fields to calculate intermediate values (which are not needed in the response) so these are @removed:

query {
  siteURL: optionValue(name: "siteurl")
    @remove
 
  requestURL: _sprintf(
    string: "%s/wp-json/wp/v2/comments/11/?_fields=id,content,date",
    values: [$__siteURL]
  )
    @remove
 
  _sendJSONObjectItemHTTPRequest(
    input: {
      url: $__requestURL
    }
  )
}

The response will not contain the @removed fields siteURL and requestURL:

{
  "data": {
    "_sendJSONObjectItemHTTPRequest": {
      "id": 11,
      "date": "2020-12-12T04:07:36",
      "content": {
        "rendered": "<p>Btw, I really like this stuff<\/p>\n"
      }
    }
  }
}