Interface GraphQlTester.Request<T extends GraphQlTester.Request<T>>

Type Parameters:
T - the type of request
Enclosing interface:
GraphQlTester

public static interface GraphQlTester.Request<T extends GraphQlTester.Request<T>>
Declare options to gather input for a GraphQL request and execute it.
  • Method Details

    • operationName

      T operationName(@Nullable String name)
      Set the operation name.
      Parameters:
      name - the operation name
      Returns:
      this request spec
    • fragment

      T fragment(String fragment)
      Append the given fragment section to the request document. A fragment describes a selection of fields to be included in the query when needed and is defined with the fragment keyword.
      Parameters:
      fragment - the fragment definition
      Returns:
      this request spec
      Since:
      1.3
      See Also:
    • fragmentName

      T fragmentName(String fragmentName)
      Variant of fragment(String) that uses the given key to resolve the GraphQL fragment document from a file with the help of the configured DocumentSource.
      Parameters:
      fragmentName - the name of the fragment to append
      Returns:
      this request spec
      Throws:
      IllegalArgumentException - if the fragmentName cannot be resolved
      Since:
      1.3
    • variable

      T variable(String name, @Nullable Object value)
      Add a variable.
      Parameters:
      name - the variable name
      value - the variable value, possibly null since GraphQL supports providing null for a value vs not providing a value at all.
      Returns:
      this request spec
    • variables

      T variables(Map<String,Object> values)
      Add variables from a Map.
      Parameters:
      values - the variables to add, possibly with null values since GraphQL supports null for a value vs not providing it at all.
      Returns:
      this request spec
      Since:
      1.3.0
    • extension

      T extension(String name, @Nullable Object value)
      Add a value for a protocol extension.
      Parameters:
      name - the protocol extension name
      value - the extension value
      Returns:
      this request spec
    • execute

      Execute the GraphQL request and return a spec for further inspection of response data and errors.
      Returns:
      options for asserting the response
      Throws:
      AssertionError - if the request is performed over HTTP and the response status is not 200 (OK).
    • executeAndVerify

      void executeAndVerify()
      Execute the GraphQL request and verify the response contains no errors.
    • executeSubscription

      GraphQlTester.Subscription executeSubscription()
      Execute the GraphQL request as a subscription and return a spec with options to transform the result stream.
      Returns:
      spec with options to transform the subscription result stream
      Throws:
      AssertionError - if the request is performed over HTTP and the response status is not 200 (OK).