Partial response and error handling

GraphQL responses can mix payloads and errors. In xDI, the GraphQL component controls error tolerance with a property in the integration template.

Error tolerance in mappings

The GraphQL integration template exposes the property Partial response errors tolerated number. This property controls when mappings should fail based on the number of partial errors returned in GraphQL responses:

  • < 0: tolerate all partial errors and keep the mapping in Success.

  • 0 (default): fail as soon as the first partial error is returned.

  • N > 0: complete the mapping unless more than N partial errors occur.

Handling partial and error responses

In GraphQL metadata, the JSON root node can contain both data and errors branches to represent succesful responses and errors.

The errors branch is an array of error objects that provide details about any issues encountered during the execution of the GraphQL operation. The error objects must follow the GraphQL specification.

Like successful responses, errors create output data that you can map to a datastore, or use to control a process. If you have configured error tolerance in the integration template, you can use both successful data and error data.