Get all Deployments with GraphQL API?
jazzychad
PROOP

3 months 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

Pinned Solution

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

4 Replies

Railway
BOT

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

3 months ago

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

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

3 months 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 3 months ago


Loading...