API Gateways (GQL)

Programmatically create, read, update, and delete API gateways and templates using the GraphQL Platform API.

API gateways

For more information on API gateways, see API Gateways.

Get API gateways

This query obtains details on API gateways, similar to the details shown on the API Gateways tab of the Admin Panel.

query getGateways {
  gatewayInstances {
    nodes {
        id
  apiGatewayCodeTemplateId
  dns
  type
  deploymentKey
  serviceStatus
  status
  isDefault
  isCanBeEdited
  template {
    id
    name
  }
  configurations {
    gatewayDefaultTimeOut
    limitRequestSize
    allowHttpTraffic
  }
  customMessages {
    id
    messageKey
    messageValue
  }
    }
  }
}
{
  "order": {
    "sortingFields": [
      {
        "fieldName": "ID",
        "order": "ASC"
      }
    ]
  }
}

Create an API gateway

This mutation creates an API gateway similarly to creating an API gateway using the API Gateways tab of the Admin Panel.

mutation createGWInstance($createDto: GatewayInstanceCreateInput!) {
  createGatewayInstance(createDto: $createDto) {
        id
  apiGatewayCodeTemplateId
  dns
  type
  deploymentKey
  serviceStatus
  status
  isDefault
  isCanBeEdited
  template {
    id
    name
  }
  configurations {
    gatewayDefaultTimeOut
    limitRequestSize
    allowHttpTraffic
  }
  customMessages {
    id
    messageKey
    messageValue
  }
  }
}
{
  "createDto": {
    "dns": "https://example.com",
    "apiGatewayCodeTemplateId": 4,
    "type": "Azure",
    "isDefault": false
  }
}

Update an API gateway

This mutation updates an API gateway similarly to updating an API gateway using the API Gateways tab of the Admin Panel. The API gateway's id can be obtained from the gatewayInstances query shown above.

mutation updateGWInstance($updateDto: GatewayInstanceUpdateInput!) {
  updateGatewayInstance(updateDto: $updateDto) {
        id
  apiGatewayCodeTemplateId
  dns
  type
  deploymentKey
  serviceStatus
  status
  isDefault
  isCanBeEdited
  template {
    id
    name
  }
  configurations {
    gatewayDefaultTimeOut
    limitRequestSize
    allowHttpTraffic
  }
  customMessages {
    id
    messageKey
    messageValue
  }
  }
}
{
  "updateDto": {
    "id": "2868",
    "apiGatewayCodeTemplateId": 64,
    "customMessages": [],
    "dns": "https://example.com",
    "isDefault": false
  }
}

Delete an API gateway

This mutation deletes an API gateway. The API gateway's id can be obtained from the gatewayInstances query shown above.

mutation deleteGWInstance($id: ID!) {
  deleteGatewayInstance(id: $id)
}
{
  "id": "2868"
}

API gateway templates

For more information on API gateway templates, see API Gateways.

Get API gateways templates

This query obtains details on API gateway templates, similar to the details shown on the API Gateways tab of the Admin Panel. There are no variables for this query.

query getGWTemplates {
  gatewayTemplates {
    nodes {
      id
      name
      description
      urlPattern
      status
      isCanBeDeleted
      createdAt
      updatedAt
      templateParams {
        id
        paramName
        paramValue
        paramDescription
        status
        createdAt
        updatedAt
      }
    }
    totalCount
  }
}

Create an API gateway template

This mutation creates an API gateway template similarly to creating an API gateway template using the API Gateways tab of the Admin Panel.

mutation createTemplate($createDto: GatewayTemplateCreateInput!) {
  createGatewayTemplate(createDto: $createDto) {
      id
  name
  description
  urlPattern
  status
  isCanBeDeleted
  createdAt
  updatedAt
  templateParams {
    id
    paramName
    paramValue
    paramDescription
    status
    createdAt
    updatedAt
  }
  }
}
{
  "createDto": {
    "description": "Example code templates",
    "name": "Example template",
    "urlPattern": "{{API_BASE_URL}}{{PATH}}",
    "headers": [
      {
        "paramName": "example-header",
        "paramValue": "exampleValue",
        "paramDescription": "Example header description"
      }
    ]
  }
}

Update an API gateway template

This mutation updates an API gateway template similarly to updating an API gateway template using the API Gateways tab of the Admin Panel. The API gateways template's id can be obtained from the gatewayTemplates query shown above.

mutation updateTemplate($updateDto: GatewayTemplateUpdateInput!) {
  updateGatewayTemplate(updateDto: $updateDto) {
      id
  name
  description
  urlPattern
  status
  isCanBeDeleted
  createdAt
  updatedAt
  templateParams {
    id
    paramName
    paramValue
    paramDescription
    status
    createdAt
    updatedAt
  }
  }
}
{
  "updateDto": {
    "id": "439",
    "description": "Example code templates updated",
    "name": "Example template",
    "urlPattern": "{{API_BASE_URL}}{{PATH}}",
    "headers": [
      {
        "paramName": "example-header",
        "paramValue": "exampleValue",
        "paramDescription": "Example header description",
        "id": "188"
      }
    ]
  }
}

Delete an API gateway template

This mutation deletes an API gateway template. The API gateway template's id can be obtained from the gatewayTemplates query shown above.

mutation deleteTemplate($id: ID!) {
  deleteGatewayTemplate(id: $id)
}
{
  "id": "439"
}