Filter deployments by environment

schema-request

#1

In the REST API it’s possible to filter deployments via the environment name, however that’s not possible in the GraphQL API, requiring full iteration of all deployments.

I think this would require a environment argument to the DeploymentsConnection.


#2

Hey @joehoyle!

Thanks for the request! I was the one who added the DeploymentsConnection recently, I assumed there would be some requests for some basic filters.

While I dive in there (hopefully this week!) Is there anything else you think would be useful?


#3

@nickvanw for filtering, it would be handy to be able to order the results, I’m not sure that is possible right now?

For the deployment object, if you are near that, currently there’s no way to get the payload of a deployment via the GraphQL api either.

Thanks!


#4

Got it! I believe there is an implicit order (though I don’t know what it is off the top of my head), definitely seems like adding some basic ordering would be good.

Deployment payload has been requested, that also is a great suggestion!

I’ll update this thread when I have more news :slight_smile:


#5

Hey @joehoyle!

I’ve gone ahead and rolled out a change to allow you to filter the Repository -> Deployments connection down by environment. The documentation should be updated shortly, and the schema change should be live. Let me know if anything looks wrong!

Something like this:

{
  repository(owner: "nickvanw", name: "repo") {
    deployments(first: 100, environments: ["production", "canary"]) {
      nodes {
        environment
      }
    }
  }
}

I’ve also got some code working to show payload, hopefully I can get that out soon :grin:


#6

Great, will give it a go now!

I’ve also got some code working to show payload, hopefully I can get that out soon :grin:

I’m sure you have it solved, but I thought if GraphQL was requiring hard typing of all data, this could be just be a JSON encoded string


#7

@nickvanw working great! Already pushed the update to production :smiley:


#8

That’s great @joehoyle!

I’ve got a pull request open to add payload as a String of encoded JSON, just like it is in the REST API. I’ll update if/when it’s deployed :smile:


#9

Hi @joehoyle!

This has been released!

{
  repository(owner: "you", name: "your_repo") {
    deployments(first: 100, environments: ["production", "schema-cache"]) {
      nodes {
        environment
        payload
        databaseId
      }
    }
  }
}

Let me know if anything contained here looks amiss, or if there’s anything else you think we’re missing!