Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Table of Contents
minLevel1
maxLevel3

Basics

Basic auth is supported for accessing FlexDeploy’s GraphQL Endpoint. Username and password or API Token are both supported.

FlexDeploy’s GraphQL Endpoint:

Code Block
http(s)://{{FLEXDEPLOY_SERVER_HOSTNAME}}:{{FLEXDEPLOY_SERVER_PORT}}/flexdeploy/rest/v2/graphql

Example:

Code Block
https://flexdeployserver.hostingservice.com:8000/flexdeploy/rest/v2/graphql

Making a Request

First, there are some steps in Postman that need to be done before writing a request.

  1. Create an HTTP Request

  2. Make sure the Request is a POST request

  3. Set the URL to the format belowendpoint listed above in Basics, replacing the {{FLEXDEPLOY_SERVER_HOSTNAME}} and {{FLEXDEPLOY_SERVER_PORT}} with your FlexDeploy server’s hostname and port respectively

    1. http(s)://{{FLEXDEPLOY_SERVER_HOSTNAME}}:{{FLEXDEPLOY_SERVER_PORT}}/flexdeploy/rest/v2/graphql

  4. Set up security information under the “Authorization” tab. Either Basic Auth (username and password) or an API token can be used here

  5. Under the “Body” tab of the request, switch the body format to GraphQL by clicking on the “GraphQL” radio button

...

The biggest difference between GraphQL and other, more traditional, REST requests are the optional selection of elements to be returned in a query. This can make queries return faster if only the information that is needed by the query is returned. This is called a subselection set. In our example we can see we have this block of text:

Code Block
languagegraphql
  items {
      endTime
      environmentName
      executionStatus
      externalTicket
      instanceName
      objectPath
      packageName
      partialDeployments
      projectName
      projectVersionName
      projectWorkflowType
      relName
      relSnapshot
      scmRevision
      startTime
      streamName
      workflowExecutionId
      workflowRequestId
  }

Here is where we can control what is being returned in the query. GraphQL will only return fields present in the subselection. For example, if I only wanted Package Name, Project Name, and Project Version Name to be returned, I could alter our previous example to something like this:

Code Block
languagegraphql
query envState($where: [WhereInput], $sort: [SortInput], $page: PageInput) {
    reportEnvironmentState(where: $where, sort: $sort, page: $page) {
        items {
            packageName
            projectName
            projectVersionName
        }
    }
}

...

Variable Name

Description

Object Definition

where: [WhereInput]

This allows you to filter the data like a where clause in an SQL query. Where is an array so multiple individual WhereInput objects can be linked together to filter the query.

field: Name of the GraphQL field being filtered

type: The comparison being performed

  • eq - equal

  • ne - not equal

  • eqi - equal (Ignores Case)

  • gt - greater than

  • lt - less than

  • inc - includes

  • inci - includes (Ignores Case)

  • ninc - does not include

  • empty - empty

  • nempty - not empty

innerWhere: Similar to a subselect in SQL where prefiltering of a query could be done

value: The value you are filtering by

Code Block
languagejson
input WhereInput {
  field: String!
  type: WhereTypeEnum!
  innerWhere: [WhereInput!]
  value: String
}

enum WhereTypeEnum {
  eq
  ne
  eqi
  gt
  lt
  inc
  inci
  ninc
  empty
  nempty
}

sort: [SortInput]

This allows you to sort the data like a order by clause in an SQL query. Sort is an array so multiple individual SortInput objects can be linked together to sort the query.

field: GraphQL field being sorted

direction: the direction of sort being preformed with asc meaning ascending order and desc meaning descending order.

Code Block
languagejson
input SortInput {
  field: String!
  direction: SortEnum
}

enum SortEnum {
  asc
  desc
}

page: PageInput

Page input contains extra options for the block of data that is returned by the query.

limit: The number of items in the block being returned. By default, a limit of 50 items are returned by the query. This can be overridden by the page limit to return a different amount of items.

offset: Offsets the block of data being returned by the set value. For example, a limit of 20 and an offset of 4 would return items 4 through 23.

Code Block
languagejson
input PageInput {
  limit: Int
  offset: Int
}

...

This is running the same query used by the Environment History Report with the Show File Details checkbox selected. It is querying the history of all FlexDeploy executions against an environment called “Build” with file-level details being returned. We have a where variable below being used to only filter for the Build environment, as well as a page variable to limit the response to only the first two items.

Code Block
languagegraphql
query reportHistoryFiles($where: [WhereInput], $sort: [SortInput], $page: PageInput) {
    reportEnvironmentHistoryFileDetails(where: $where, sort: $sort, page: $page) {
        items {
            allFilesRequested
            cmsTicketIds
            endTime
            environmentId
            environmentName
            executionStatus
            folderId
            instanceId
            instanceName
            workItemIds
            objectPath
            packageName
            partialDeployments
            pkgStatus
            poScmRevision
            projectId
            projectName
            projectVersionName
            relDefinitionId
            relName
            relSnapshot
            relSnapshotId
            requestedBy
            requestedOn
            scmRevision
            sequenceNumber
            stageExecId
            startTime
            streamName
            workflowExecutionId
            workflowId
            workflowRequestId
            workflowType
            workflowVersion
        }
    }
}

...

This is querying the history of our production environments for deployments that failed with file details not being returned. We also want the most recent failed deployment so we will be sorting by date.

Code Block
languagegraphql
query reportHistoryNoFiles($where: [WhereInput], $sort: [SortInput], $page: PageInput) {
    reportEnvironmentHistoryNoFileDetails(where: $where, sort: $sort, page: $page) {
        items {
            allFilesRequested
            cmsTicketIds
            endTime
            environmentId
            environmentName
            executionStatus
            folderId
            instanceId
            instanceName
            workItemIds
            objectPath
            packageName
            partialDeployments
            pkgStatus
            poScmRevision
            projectId
            projectName
            projectVersionName
            relDefinitionId
            relName
            relSnapshot
            relSnapshotId
            requestedBy
            requestedOn
            scmRevision
            sequenceNumber
            stageExecId
            startTime
            streamName
            workflowExecutionId
            workflowId
            workflowRequestId
            workflowType
            workflowVersion
        }
    }
}

...