Create GraphQL Query (Classic)
This topic describes how to create a GraphQL query.
Before you begin
- Log in to Operations Hub classic version.
- Create the GraphQL data source that you want to use in the query.
About this task
Procedure
-
In classic Operations Hub navigation menu, select
QUERIES.
The QUERIES workspace appears.
-
Select Add new query.
The New Query screen appears.
-
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.
-
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.
-
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.
-
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.
- Explore or search the nested structure and select check boxes for the fields you want to include.
- Select Create JSON to generate the
corresponding query structure.
The generated content appears in the Default or Test Value read-only preview box.
- To close the schema browser, select Browse once again.
To add a different body parameter, select
to remove the current entry.
-
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. - Enter a name for the new entity.
- Select Create.
Once created, go to the top of the screen where the query name is shown. Refer to entity field.
- From the Entity dropdown, select the entity you just created.
-
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.
- Save the query.