Create GraphQL Query (Classic)

This topic describes how to create a GraphQL query.

Before you begin

About this task

When you create a GraphQL query in Operations Hub, you configure several sections that define how the query works and how it connects to your GraphQL data source. Not all sections are mandatory. Use only the fields required by your specific query.

Procedure

  1. In classic Operations Hub navigation menu, select QUERIES.
    The QUERIES workspace appears.
  2. Select Add new query.
    The New Query screen appears.
General: Basic information related to the GraphQL query.
  1. Enter these details:
    Field Description
    Name Enter a name for the query. This name is used to reference the query when binding it to a widget.
    Tip:
    Choose a name that reflects what the query will retrieve. For example, getProductionOrders.
    Type Select GraphQL from the dropdown list. Additional configuration fields will appear.
    Data Source Select the GraphQL data source you previously created.
    Base URL Automatically populated based on the selected data source.
    Query URL The endpoint path for your GraphQL data source. A common path is /graphql, but this may differ based on your API setup.
    Description (Optional) Enter a brief summary of what this query does or what data it retrieves.
    Entity (Optional) You can choose an existing entity from the reusable entity classes that were already created within the same environment.
    Note:
    If you are creating a new entity from query results, you can return to this field and select it later.

    Refer to create entity from result field.

GraphQL Variables: Define dynamic input values for your GraphQL query.
  1. Select Add Query Param and enter these details:
    You can add multiple variables as needed.
    Field Description
    Key Enter the variable name.
    Type Allows the value to be dynamically provided from an input field defined in the App.
    Default or Test Value Enter a test value to preview query results or define a default value to be used at runtime.

    To remove a variable, select next to the variable entry.

Header Parameters: Define custom HTTP headers that should be included in the GraphQL request.
  1. Select Add Query Param and enter these details:
    You can add multiple headers as needed.
    Field Description
    Key Enter the name of the HTTP header.
    Type Select how the value will be provided:
    • Fixed Value: Use this option to enter a static value.
    • Input Field: Use this option to bind the value to an input defined in the App.
    Default or Test Value Enter a test value to preview query results or define a default value to be used at runtime.

    To remove a header, select next to the header entry.

Body Parameters: The fields you define here become part of the request body sent to your GraphQL data source.
  1. Select Add Body Param and enter these details:
    Field Description
    Value Key Enter the name of the parameter. This should match what the GraphQL API expects in the request body.
    Type Select how the value will be defined:
    • Fixed Value: Use this option to enter a static value. The query remains the same and is fixed in the body of the request.
    • Input Field: Use this option to bind the value to an input defined in the App. This allows the query to accept dynamic values at runtime.
    Browse Schema Select Browse to open the schema browser, which loads the GraphQL schema from your data source.

    The schema defines the available data types and their fields.

    1. Explore or search the nested structure and select check boxes for the fields you want to include.
    2. Select Create JSON to generate the corresponding query structure.

      The generated content appears in the Default or Test Value read-only preview box.

    3. To close the schema browser, select Browse once again.

    To add a different body parameter, select to remove the current entry.

Execute: Run the query and preview the structure of the returned data.
  1. Do the following:
    Note:
    If you are updating an existing query, keep in mind that running the request or creating an entity may overwrite or replace existing query results or entity definitions tied to this configuration. This change could impact how data is bound to widgets in your App and may require reconfiguration.
    Field Description
    Run Request Select this button to execute the configured GraphQL query.

    The column names from the returned JSON are automatically extracted and shown in the Execute Result read-only box. It shows the raw JSON returned by the data source. Use it to confirm that the query is working and to understand the structure of the data before creating an entity.

    Create entity from results Select this button to open a Create Entity dialog screen.
    1. Enter a name for the new entity.
    2. Select Create.

      Once created, go to the top of the screen where the query name is shown. Refer to entity field.

    3. From the Entity dropdown, select the entity you just created.
Output Data: Select the fields to return from the query for display in widgets.
  1. Select the relevant option to add output fields.

    You can include one or more output fields in your query, depending on what data you want to visualize. Select only what’s relevant to avoid unnecessary data processing.

    Add Field Add specific fields individually. Useful when you only need a subset of the available output fields.
    Add All Fields Add all available fields from the entity to the output. Recommended if you want to return all columns from the query.
    Note:
    The available output fields are based on the structure of the selected entity. These fields reflect the data returned by your query and may vary depending on the use case.

    To remove an output field from the query, select next to the output dropdown entry.

  2. Save the query.

What to do next

Use GraphQL Data in Operations Hub