Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

CONNECT data services developer documentation

Graph QL

  • Last UpdatedJul 23, 2024
  • 4 minute read

The GraphQL Asp.net Core controller.

Graph QL Get

Executes a GraphQL Query or Mutation based on the query arguments of a GET request.
It returns a GraphQLResponse in JSON format. The format of the response varies depending on the request.
For more details specific to GraphQL, see the GraphQL POST method (it is the recommended approach for working with GraphQL).

Request

GET /api/v1.0-preview/tenants/{tenantId}/namespaces/{namespaceId}/graphql
?graphql={graphql}&variables={variables}&operationName={operationName}&continuation={continuation}&metrics={metrics}

Parameters

string tenantId
Tenant identifier.

string namespaceId
Namespace identifier.

string graphql
The GraphQL query or mutation.

[optional] string variables
One or more named variables and their values that support the query. This is a serialized Dictionary<string, object?>. The object is the variable value and can be a scalar or any supported schema type or type collection (serialized JSON).

[optional] string operationName
The name of the operation.

[optional] string continuation
Additional data for querying the next page of data. Use this when the GraphQL response has a continuation token in its extension data.

[optional] boolean metrics
Enables collection of metrics. These are added to the GraphQL response in its extension data.

Response

Status Code Body Type Description
200 IGraphQLResponse Received and processed. GraphQL always returns a 200 response unless the request is unprocessable.
Errors are returned in the GraphQLResponse errors collection.
If the error collection is not empty, then all or part of the operation failed. See the POST method for possible error codes.

Example response body

200 Response

{
  "data": {
    "events": {
      "upsertAlarm": [
        {
          "id": "alarm_0001"
        }
      ]
    }
  },
  "errors": [
    {
      "message": "Optimistic concurrency error",
      "path": [
        "Alarm[id: alarm_0002]"
      ],
      "extensions": {
        "code": "OPTIMISTIC_CONCURRENCY_ERROR"
      },
      "data": {
        "id": "alarm_0002"
      }
    }
  ]
}

Graph QL Post

Executes a GraphQL Query or Mutation based on the GraphQLRequest body content in a POST request.
The query or mutation will run against a loaded GraphQL schema that defines all the Types and APIs available for a namespace.
The request query property contains the GraphQL query or mutation.
The request variables property can be used to pass named values into a query or mutation. The value can be a scalar or any schema defined type or type collection (serialized JSON).
It returns a GraphQLResponse in JSON format. The format of the response varies depending on the request.

Request

POST /api/v1.0-preview/tenants/{tenantId}/namespaces/{namespaceId}/graphql
?continuation={continuation}&metrics={metrics}

Parameters

string tenantId
Tenant identifier.

string namespaceId
Namespace identifier.

[optional] string continuation
Additional data for querying the next page of data. Use this when the GraphQL query response has a continuation token in its extension data.

[optional] boolean metrics
Enables collection of metrics. These are added to the GraphQL response in its extension data.

Request Body

A GraphQLRequest that represents a query or mutation.

{
  "query": "query ($varinput1: Int!) { referenceData { queryAlarmSeverityCat ( where: { severity: { gt: $varinput1 } } options: { sort: { severity: DESC }, count: 2 } ) { id color severity } } }",
  "variables": {
    "varinput1": 1
  }
}

Response

Status Code Body Type Description
200 IGraphQLResponse Received and processed. GraphQL always returns a 200 response unless the request is unprocessable.
Errors are returned in the GraphQLResponse errors collection.
If the error collection is not empty, then all or part of the operation failed.

The following lists possible error codes for ANY operations...
- SYSTEM_ERROR (same as Http 500)
- GRAPHSTORE_SYSTEM_ERROR (same as Http 500)
- SERVICE_UNAVAILABLE (same as Http 503)
- VALIDATION_ERROR (same as Http 400) - see the error message for more details
- COMPLEXITY (same as Http 400) - see the error message for more details

The following lists possible error codes for QUERY operations...
- SYNTAX_ERROR (same as Http 400) - there may be other GraphQL specific codes for these, but all are syntax errors
- VALIDATION_WARNING (same as Http 200, but all data may not have been returned) - see the error message for more details

The following lists possible error codes for UPSERT operations...
- OPTIMISTIC_CONCURRENCY_ERROR (same as Http 412)
- FORBIDDEN_ERROR (same as Http 403)
- TOPLEVEL_NODE_LIMIT_EXCEEDED (same as Http 400)
- TOTAL_NODE_LIMIT_EXCEEDED (same as Http 207) - some data may not have been written

The following lists possible error codes for DELETE operations...
- NOT_FOUND_ERROR (same as Http 404)
- CONFLICT_ERROR (same as Http 409)
- TOPLEVEL_NODE_LIMIT_EXCEEDED (same as Http 400)
413 Inline Payload Too Large. The max request body size is 3276800 bytes.

Example response body

200 Response

{
  "data": {
    "referenceData": {
      "queryAlarmSeverityCat": [
        {
          "id": "critical",
          "color": "red",
          "severity": 2
        },
        {
          "id": "notice",
          "color": "blue",
          "severity": 8
        }
      ]
    }
  },
  "errors": null,
  "extensions": {
    "continuation": "eyJJZCI6IjdhZGNkMzEwYzIxYjQ4MmM4MGRiZjQ4OTE3ZWZiM2FlIiwiVHlwZUlkIjoiQWxhcm1FdmVudFR5cGUifQ%3d%3d"
  }
}

Definitions

IGraphQLResponse

Properties

Property Name Data Type Required Nullable Description
Data any false false None
Errors [GraphQLError] false true None
Extensions Map false true None
{
  "Data": null,
  "Errors": [
    {
      "Locations": [
        {
          "Column": 0,
          "Line": 0
        }
      ],
      "Message": "string",
      "Path": {
        "_items": [
          null
        ],
        "_size": 0,
        "Capacity": 0,
        "Count": 0,
        "Item": null
      },
      "Extensions": {}
    }
  ],
  "Extensions": {}
}


GraphQLError

Properties

Property Name Data Type Required Nullable Description
Locations [GraphQLLocation] false true None
Message string false false None
Path ErrorPath false true None
Extensions Map false true None
{
  "Locations": [
    {
      "Column": 0,
      "Line": 0
    }
  ],
  "Message": "string",
  "Path": {
    "_items": [
      null
    ],
    "_size": 0,
    "Capacity": 0,
    "Count": 0,
    "Item": null
  },
  "Extensions": {}
}


GraphQLLocation

Properties

Property Name Data Type Required Nullable Description
Column integer false false None
Line integer false false None
{
  "Column": 0,
  "Line": 0
}


ErrorPath

Properties

Property Name Data Type Required Nullable Description
_items [any] false false None
_size int32 false false None
Capacity int32 false false None
Count int32 false false None
Item any false false None
{
  "_items": [
    null
  ],
  "_size": 0,
  "Capacity": 0,
  "Count": 0,
  "Item": null
}


Map

{}


GraphQLRequest

Properties

Property Name Data Type Required Nullable Description
OperationName string false true None
Query string false true None
Variables Inputs false true None
Extensions Inputs false true None
{
  "OperationName": "string",
  "Query": "string",
  "Variables": {},
  "Extensions": {}
}


Inputs

{}


In This Topic
Related Links
TitleResults for “How to create a CRG?”Also Available in