Get all Deployments with GraphQL API?
jazzychad
PROOP

19 days ago

I am running the graphql query to fetch the deployments for a specified Service. On the web dashboard I can see the active deployment as well as the "History" section which shows all previous deployments.

When I run the graphql query, it only returns the active/running deployment, and the pageInfo says there are no other pages or cursors to use, so I am not sure how to fetch the "historic" deployments that are no longer running...?

Query:

query {
  service(id: "99c...") {
    name
    deployments {
      pageInfo {
        hasNextPage
        hasPreviousPage
        startCursor
        endCursor
      }
      edges {
        cursor
        node {
          id
          createdAt
          status
        }
      }
    }
  }
}

Response:

{
  "data": {
    "service": {
      "name": "my-service-name",
      "deployments": {
        "pageInfo": {
          "hasNextPage": false,
          "hasPreviousPage": false,
          "startCursor": "R1BDO...",
          "endCursor": "R1BDO..."
        },
        "edges": [
          {
            "cursor": "R1BDO...",
            "node": {
              "id": "2fc55...",
              "createdAt": "2025-11-17T21:58:06.721Z",
              "status": "SUCCESS"
            }
          }
        ]
      }
    }
  }
}

fwiw I am using an API Token with no workspace scope and using the Authorization: Bearer xyz... header

Solved$40 Bounty

4 Replies

Railway
BOT

19 days ago

Hey there! We've found the following might help you get unblocked faster:

If you find the answer from one of these, please let us know by solving the thread!


You need to directly query the deployments field.

Example query:

query Deployments($serviceId: String!, $projectId: String!, $environmentId: String!) {
  deployments(
    first: 50
    input: {projectId: $projectId, serviceId: $serviceId, environmentId: $environmentId}
  ) {
    edges {
      node {
        id
        createdAt
        status
      }
    }
  }
}

If you happen to be using Typescript, you can use this community maintained SDK too

Here's how you'd do it:
https://github.com/crisog/railway-sdk/blob/main/examples/deployments.ts


0x5b62656e5d

You need to directly query the deployments field.Example query:query Deployments($serviceId: String!, $projectId: String!, $environmentId: String!) { deployments( first: 50 input: {projectId: $projectId, serviceId: $serviceId, environmentId: $environmentId} ) { edges { node { id createdAt status } } } }

jazzychad
PROOP

17 days ago

Yeah, I discovered this solution, too. While it seems to be the only supported way to get these past deployments, it would be nice if the structured graphql query would also return them. Thanks!


Status changed to Solved noahd 17 days ago


Loading...