How to retrieve Deployments for a Repository?

schema-request

#1

Hi there!

I’m having trouble getting a list of Deployments that are attached to a Repository. I see the Object in the documentation, but I don’t see a connection from a Repository. Has anyone else had any luck with this?

  • Morgan

#2

Hey @mdelagrange!

Thanks for the post - it looks like we’re missing that connection indeed! I’ve added this to our project board, I’ll update this issue when it’s available!


#3

Great thanks Nick!


#4

Hey @mdelagrange!

We just shipped the ability to list Deployments for a Repository, you can see an example if you run a query such as:

{
  user(login: "node") {
    repositories(first: 100) {
      nodes {
        name
        deployments(first: 100) {
          nodes {
            commit {
              oid
            }
            state
            id
          }
        }
      }
    }
  }
}

If you have any further requests here, or if something doesn’t appear correct, let me know!


#5

Looks good @nickvanw! There are some fields in the REST API (https://developer.github.com/v3/repos/deployments/#get-a-single-deployment) that aren’t present here. A couple of them are used by my organization in our production code:

id: This is a sequential number that’s used for retrieving deployments and creating statuses in the REST API. The id returned in the GraphQL API is a GraphQL ID, not the deployment id. You may want to add something like deployment_id to maintain compatibility with existing deployment numbers?
payload: This is a place to attach arbitrary metadata to a deploy. (In our case, we store the SHA of the previous deployment to that environment, so that we can link to each deploy’s changes in Hubot.)

Payload may be particularly challenging. Can you return arbitrary data in a GraphQL query? If not, maybe it won’t be possible to fully support deployments in the GraphQL API.

Thanks!

  • Morgan

#6

Hi @mdelagrange,

I’ve added those two fields as a schema request in our internal issue tracker. We’ll update you here when we have some more information to share.


#7

Sounds good, thanks!


#8

Hi @mdelagrange!

We just released the ability to fetch both of these fields via a GraphQL request:

{
  repository(owner: "blah", name: "blah") {
    deployments(first: 100, environments: ["production"]) {
      nodes {
        environment
        payload
        databaseId
      }
    }
  }
}

Thanks again for your feedback, and don’t hesitate to reach out if there’s anything else!