[GraphQL] - Get deployed build on a particular environment


Is there a way using the GraphQL API to get the deployed build on a particular environment? Currently, I am doing this by getting every single execution and on the client side sorting them by date. Is there a better way?

@chanan if I had to do this, I would use the executions query in the API.

You can use the Filter to filter by a specific service, environment, and status of success. Then, if you set offset to 0 and limit to 1, you should get the most recent successful deployment of a specific service to a specific environment

Hi @sneakyaneurysm that assumes that the results are order by date descending, Is that the case? I thought I was once told that the results are in random order, but maybe I am mis remembering

I’m not aware of a “Random Sort”, but I could be wrong. If you define which fields you’re most interested in for the query, one of those could be end time, and then just sort it by end time and grab the top result.

Yes that is what I am currently doing, which was working fine for a while, the problem is I have to do it for many applications at once for one operation, and I hitting the rate limit of queries now that our usage of harness has grown in the past year.

I can get by for now, because I noticed that in that location of code I am not filtering by environment, so that can be improved, but I assume we wil hit this problem again in the future

Have you looked into the deploymentStats option?

You can use filter and sort by there

No, a while back I tried to figure out how to use it, but moved on, I will take another look, thanks for the suggestion!

1 Like