Skip to main content

GraphQL

Supported test-directives

Qapir supports GraphQL and enables you to test GraphQL APIs. The supported directives are:

  1. expected_http_status of type number - verifies that response has expected HTTP-status
  2. graphql_query of type string - lets you pass a query to your GraphQL-request
  3. graphql_variables of type map[string]any - lets you pass variables to your GraphQL-request
  4. graphql_operation_name of type string - lets you pass an operationName to your GraphQL-request
  5. graphql_extensions of type map[string]any - lets you pass extensions to your GraphQL-request
  6. method of type string - an HTTP-method, one of [GET, POST]

QTL-directives

  1. Extracting a value by jsonpath from response-body. This example looks for field with jsonpath $.path.to.attribute and saves its value as ${var.attribute}
SELECT
$.path.to.attribute AS ${var.attribute}
FROM
${response.body};
  1. Extracting a header-value. This example looks for header with name Custom-Header and saves its value as ${var.header}
SELECT
Custom-Header AS ${var.header}
FROM
${response.headers};

Examples

Please, check out related examples in the official GitHub repo: https://github.com/vrtxlabs/qapir/blob/main/.qapir/tests/graphql_test.yml