Versions Compared

Key

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

...

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
        }
    }
}

...

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
        }
    }
}

...