Is it possible to query using GraphQL to lookup a ...
# ask-community
b
Is it possible to query using GraphQL to lookup a Job and its past run and next upcoming run
t
You can get the past runs (successful) by running a query like the below (perhaps there is a better endpoint to use). And it looks like you can use the statuses filter to query QUEUED, NOT_STARTED, STARTING etc. Someone with more knowledge can correct any of this
Copy code
query FilteredRunsQuery {
  runsOrError(filter: { statuses: [SUCCESS], pipelineName: "my_job_name_goes_here" }) {
    __typename
    ... on Runs {
      results {
        runId
        jobName
        status
        runConfigYaml
        startTime
        endTime
      }
    }
  }
}
That query will return results like the below. Not sure if this helps
Copy code
{
  "data": {
    "runsOrError": {
      "__typename": "Runs",
      "results": [
        {
          "runId": "b73b1b20-46d5-4efa-a47d-a73bb207ddf9",
          "jobName": "my_job_name_goes_here",
          "status": "SUCCESS",
          "runConfigYaml": "{}\n",
          "startTime": 1693238409.189392,
          "endTime": 1693238566.937148
        },
     ...
     ...
b
Thanks Todd, for successful jobs
SUCCESS
is correct, but for next future run,
QUEUED, NOT_STARTED, STARTING
will not work, because if the schedule is for next day or day after, the tick has not been created or added and so there will be no DB entry to check that