Unetus Docs
  • Documentation
  • Download
    • Introduction
    • Install
    • Send Your First Request
    • Import and Export Data
    • Environment Variables
    • Workspaces
    • Requests
    • Responses
    • Request Collections
    • Request Timeouts
    • Chaining Requests
    • Post CSV Data
    • SOAP Requests
    • gRPC
    • WebSocket Support
    • Get Started with Documents
    • Design Documents
    • Linting
    • GraphQL for OpenAPI
    • Unit Testing
    • Stress Testing
    • Authentication
    • Client Certificates
    • Generate Code Snippet
    • Cookie Management
    • Encoding
    • GraphQL Queries
    • Key Maps
    • Proxy
    • Insomnia Configuration File
    • Introduction to Plugins
    • Context Object Reference
    • Template Tags
    • Hooks and Actions
    • Custom Themes
    • FAQ
    • Application Data
    • SSL Validation

GraphQL Queries

GraphQL is a query language for APIs that uses a type system to help with correctness and maintainability. Unetus makes use of this type system to provide auto-completion and linting of GraphQL queries. This article will explain how to create and execute GraphQL queries within Unetus.

Using GraphQL

Creating a GraphQL request in Unetus is easy. It can be done by either selecting the GraphQL request type during creation or by changing the body type of an existing request using the body menu.

Once this is done, you can fill in the query and variables section of the query.

Query Section

The query is the only required field of a GraphQL request. Queries can include arguments, comments, fragment, as well as any other valid query constructs. While editing the query, Unetus will provide auto-completion and errors messages based on the API schema.

Note: GraphQL queries cannot include Unetus templating but variables can.

Variables Section

GraphQL variables are defined in the Query Variables section below the query. Variables must be defined as a valid JSON object and can include Environment Variables and Template Tags if desired. If the variables section is left empty the variables attribute will not be included in the request payload.

Construct the Request Payload

Unetus automatically constructs the payload of a GraphQL request and saves it whenever the query or variables sections are modified. There are three possible attributes that make up a GraphQL request.

  • query (string): The GraphQL query to be sent.
  • variables (object): An optional object of variables to be included with the query.
  • operationName (string): An optional operation name, populated automatically using the first named query if one exists.

The following is an example of a GraphQL request payload that makes use of all three parameters.

{
    "query": "query MyQuery($id: string) { thing(id: $id) { id name created } }",
    "variables": {
        "id": "thing_123"
    },
    "operationName": "MyQuery"
}

Note: It may be useful to know that this is how Unetus stores the request body behind the scenes. Try converting the body type to JSON and back and see for yourself.

Schema Fetching

To provide auto-complete and error checking of GraphQL queries, Unetus automatically fetches the schema by sending an introspection query. This query is performed both when switching to a new GraphQL request in the app or when various properties of the request are modified (eg. URL).

Note: All attributes of the request (authentication, headers, etc) are also sent with the introspection query

Documentation Browser

Unetus supports the ability to browse the documentation for the current GraphQL endpoint.

There are three ways to show the documentation pane.

  1. Click Show Documentation in the Schema dropdown near the query.
  2. Hover over a field and click within the popup documentation.
  3. Control+click (on Mac) a field within a query.
Edit this page
Report an issue
© 2021-2023 Kong Inc.
© 2023 Unetus Project