Interface GraphQlResponse

All Known Subinterfaces:
ClientGraphQlResponse, ExecutionGraphQlResponse
All Known Implementing Classes:
AbstractGraphQlResponse, DefaultExecutionGraphQlResponse, RSocketGraphQlResponse, WebGraphQlResponse

public interface GraphQlResponse
Represents a GraphQL response with the result of executing a request operation.
Since:
1.0.0
Author:
Rossen Stoyanchev
  • Method Summary

    Modifier and Type
    Method
    Description
    field(String path)
    Navigate to the given path under the "data" key of the response map where the path is a dot-separated string with optional array indexes.
    <T> T
    Return the data part of the response, or null when the response is not valid.
    Return errors included in the response.
    Return implementor specific, protocol extensions, if any.
    boolean
    Whether the response is valid.
    Return a map representation of the response, formatted as required in the "Response" section of the GraphQL spec.
  • Method Details

    • isValid

      boolean isValid()
      Whether the response is valid. A response is invalid in one of the following two cases:
      • the response map has no "data" entry indicating errors before execution, e.g. grammar parse and validation
      • the "data" entry has a null value indicating errors during execution that prevented a valid response

      A valid response has a "data" key with a non-null value, but it may still be partial and have some fields set to null due to field errors.

      For more details, see section 7 "Response" in the GraphQL spec.

    • getData

      @Nullable <T> T getData()
      Return the data part of the response, or null when the response is not valid.
      Type Parameters:
      T - a map or a list
    • getErrors

      List<ResponseError> getErrors()
      Return errors included in the response.

      A response that is not valid contains "request errors". Those are errors that apply to the request as a whole, and have an empty error path.

      A response that is valid may still be partial and contain "field errors". Those are errors associated with a specific field through their error path.

    • field

      ResponseField field(String path)
      Navigate to the given path under the "data" key of the response map where the path is a dot-separated string with optional array indexes.

      Example paths:

       "hero"
       "hero.name"
       "hero.friends"
       "hero.friends[2]"
       "hero.friends[2].name"
       
      Parameters:
      path - relative to the "data" key
      Returns:
      representation for the field with further options to inspect or decode its value; use ResponseField.getValue() to check if the field actually has a value.
    • getExtensions

      Map<Object,Object> getExtensions()
      Return implementor specific, protocol extensions, if any.
    • toMap

      Map<String,Object> toMap()
      Return a map representation of the response, formatted as required in the "Response" section of the GraphQL spec.