...
Table of Contents | ||||
---|---|---|---|---|
|
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.
Create an HTTP Request
Make sure the Request is a POST request
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
http(s)://{{FLEXDEPLOY_SERVER_HOSTNAME}}:{{FLEXDEPLOY_SERVER_PORT}}/flexdeploy/rest/v2/graphql
Set up security information under the “Authorization” tab. Either Basic Auth (username and password) or an API token can be used here
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 | ||
---|---|---|
| ||
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 | ||
---|---|---|
| ||
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
innerWhere: Similar to a subselect in SQL where prefiltering of a query could be done value: The value you are filtering by |
| |||||
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. |
| |||||
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. |
|
...
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 | ||
---|---|---|
| ||
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 | ||
---|---|---|
| ||
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 } } } |
...