Target Management via the GraphQL API

Targets can be managed via the Hive Console GraphQL API. For more information, please refer to our target documentation.

Retrieve a Single Target

Use the Query.target field to retrieve a target either by its id or slug selector.

query TargetById($targetId: ID!) {
  target(reference: { byId: $targetId }) {
    id
    slug
  }
}
Loading tree-sitter...

Retrieve a List of Targets within a Project

Use the Project.targets field to retrieve a list of targets within the organization. Note: This field will currently return all targets within the project.

query TargetById($projectId: ID!) {
  project(reference: { byId: $projectId }) {
    id
    targets {
      edges {
        node {
          id
          slug
        }
      }
      pageInfo {
        hasNextPage
        endCursor
      }
    }
  }
}
Loading tree-sitter...

Create a Target

Use the Mutation.createTarget field for creating a new target within a project.

mutation CreateTarget($input: CreateTargetInput!) {
  createTarget(input: $input) {
    ok {
      createdTarget {
        id
        slug
      }
    }
    error {
      message
    }
  }
}
Loading tree-sitter...

Update the Target GraphQL Endpoint URL

Use the Mutation.updateTargetGraphQLEndpointUrl field for updating the GraphQL endpoint url that is used in the laboratory for querying the GraphQL server.

mutation UpdateTargetGraphQLEndpointUrl($input: UpdateTargetGraphQLEndpointUrlInput!) {
  updateTargetGraphQLEndpointUrl(input: $input) {
    ok {
      target {
        id
        slug
      }
    }
    error {
      message
    }
  }
}
Loading tree-sitter...

Update the Breaking Change Configuration

Use the Mutation.updateTargetConditionalBreakingChangeConfiguration field for updating the conditional breaking change configuration.

mutation UpdateTargetConditionalBreakingChangeConfiguration(
  $input: UpdateTargetConditionalBreakingChangeConfigurationInput!
) {
  updateTargetConditionalBreakingChangeConfiguration(input: $input) {
    ok {
      target {
        id
        slug
        conditionalBreakingChangeConfiguration {
          isEnabled
          period
          percentage
          requestCount
          breakingChangeFormula
          targets {
            id
            slug
          }
          excludedClients
        }
      }
    }
    error {
      message
    }
  }
}
Loading tree-sitter...

Update Dangerous Change Classification

Use the Mutation.updateTargetDangerousChangeClassification field to set whether dangerous schema changes should fail a schema check (if they are not safe based on usage).

mutation UpdateTargetGraphQLEndpointUrl($input: UpdateTargetDangerousChangeClassificationInput!) {
  updateTargetDangerousChangeClassification(input: $input) {
    ok {
      target {
        id
        slug
      }
    }
    error {
      message
    }
  }
}
Loading tree-sitter...