Xray GraphQL API: How to retrieve newest test execution records first

I’m working on setting up an automated workflow for Xray Test Executions in Jira Cloud and running into a sorting issue.

I’m using a GraphQL query to fetch test execution data like this:

POST Request
Payload: {"query": "{getTestExecutions(jql: \"project = 'DEF' and status = 'PASS'\", limit: 100) {results {issueId}}}"}

The problem is my JQL returns more than 100 records, but the API always gives me the oldest ones first. I need the most recent test executions instead, typically those from the past week.

I’ve tried a couple approaches without success:

  1. Adding ‘order by created DESC’ to my JQL query doesn’t seem to work
  2. I heard about a ‘modifiedSince’ parameter but can’t figure out the right syntax to filter for recent items only

Has anyone dealt with this before? I just need to get the newest test execution IDs rather than the oldest ones. Any suggestions would be really helpful.

Thanks!

Had this exact issue last month building our CI integration. GraphQL endpoint handles ordering differently than the REST API. What worked for me was combining both approaches - use modifiedSince to narrow down your dataset first, then apply JQL ordering within that filtered set. The syntax should be {getTestExecutions(jql: "project = 'DEF' and status = 'PASS' ORDER BY created DESC", modifiedSince: "2024-01-08T00:00:00Z", limit: 100)}. Capitalize ORDER BY exactly like that. Key thing I learned: modifiedSince acts as a pre-filter before JQL gets processed, so you get way better performance and ordering actually works as expected.

Yeah, modifiedSince is definitely the way to go. I ran into the same thing pulling recent test data from Xray’s API. Just format it as an ISO date string in your GraphQL query like this: {getTestExecutions(jql: "project = 'DEF' and status = 'PASS'", modifiedSince: "2024-01-15T00:00:00Z", limit: 100)}. Swap in whatever date range you need - I usually go back 7-10 days just to be safe. JQL ordering gets weird with GraphQL endpoints vs REST, so filtering by date works way better than trying to sort through hundreds of old records.

try using the start parameter along with your limit for pagination. like fetch 0-99 first, then increase the start value to get more recent ones. also, check your JQL orderin – sometimes a small syntax err can mess it up.