Skip to content

Update GraphQL endpoint to support sorting releases

Nathan Friend requested to merge nfriend-add-graphql-release-sorting into master

What does this MR do?

Updates our GraphQL endpoint to support sorting of releases by released_at and created_at.

This is essentially the same change as !44118 (merged), but for GraphQL instead of our REST API.

This MR is an incremental step towards #26413 (closed).

Example queries/responses

No sort provided (same as sort: RELEASED_AT_DESC)

Query:

{
  project(fullPath: "root/release-test") {
    releases(first: 3) {
      nodes {
        createdAt
        releasedAt
      }
      pageInfo {
        startCursor
        endCursor
      }
    }
  }
}

Response:

{
  "data": {
    "project": {
      "releases": {
        "nodes": [
          {
            "createdAt": "2020-09-02T18:13:36Z",
            "releasedAt": "2030-03-15T08:00:00Z"
          },
          {
            "createdAt": "2020-09-22T00:22:27Z",
            "releasedAt": "2020-09-22T00:22:27Z"
          },
          {
            "createdAt": "2020-09-02T17:02:55Z",
            "releasedAt": "2020-09-02T17:02:55Z"
          }
        ],
        "pageInfo": {
          "startCursor": "eyJpZCI6IjQ0In0",
          "endCursor": "eyJpZCI6IjQzIn0"
        }
      }
    }
  }
}
With sort: RELEASED_AT_DESC

Query:

{
  project(fullPath: "root/release-test") {
    releases(first: 3, sort: RELEASED_AT_DESC) {
      nodes {
        createdAt
        releasedAt
      }
      pageInfo {
        startCursor
        endCursor
      }
    }
  }
}

Response:

{
  "data": {
    "project": {
      "releases": {
        "nodes": [
          {
            "createdAt": "2020-09-02T18:13:36Z",
            "releasedAt": "2030-03-15T08:00:00Z"
          },
          {
            "createdAt": "2020-09-22T00:22:27Z",
            "releasedAt": "2020-09-22T00:22:27Z"
          },
          {
            "createdAt": "2020-09-02T17:02:55Z",
            "releasedAt": "2020-09-02T17:02:55Z"
          }
        ],
        "pageInfo": {
          "startCursor": "eyJpZCI6IjQ0In0",
          "endCursor": "eyJpZCI6IjQzIn0"
        }
      }
    }
  }
}
With sort: RELEASED_AT_ASC

Query:

{
  project(fullPath: "root/release-test") {
    releases(first: 3, sort: RELEASED_AT_ASC) {
      nodes {
        createdAt
        releasedAt
      }
      pageInfo {
        startCursor
        endCursor
      }
    }
  }
}

Response:

{
  "data": {
    "project": {
      "releases": {
        "nodes": [
          {
            "createdAt": "2020-07-06T15:35:22Z",
            "releasedAt": "2020-07-06T15:35:22Z"
          },
          {
            "createdAt": "2020-07-09T19:20:06Z",
            "releasedAt": "2020-07-09T19:20:06Z"
          },
          {
            "createdAt": "2020-07-09T20:11:33Z",
            "releasedAt": "2020-07-09T20:11:33Z"
          }
        ],
        "pageInfo": {
          "startCursor": "eyJpZCI6IjEifQ",
          "endCursor": "eyJpZCI6IjMifQ"
        }
      }
    }
  }
}
With sort: CREATED_DESC

Query:

{
  project(fullPath: "root/release-test") {
    releases(first: 3, sort: CREATED_DESC) {
      nodes {
        createdAt
        releasedAt
      }
      pageInfo {
        startCursor
        endCursor
      }
    }
  }
}

Response:

{
  "data": {
    "project": {
      "releases": {
        "nodes": [
          {
            "createdAt": "2020-09-22T00:22:27Z",
            "releasedAt": "2020-09-22T00:22:27Z"
          },
          {
            "createdAt": "2020-09-02T18:13:36Z",
            "releasedAt": "2030-03-15T08:00:00Z"
          },
          {
            "createdAt": "2020-09-02T17:02:55Z",
            "releasedAt": "2020-09-02T17:02:55Z"
          }
        ],
        "pageInfo": {
          "startCursor": "eyJpZCI6IjQ2In0",
          "endCursor": "eyJpZCI6IjQzIn0"
        }
      }
    }
  }
}
With sort: CREATED_ASC

Query:

{
  project(fullPath: "root/release-test") {
    releases(first: 3, sort: CREATED_ASC) {
      nodes {
        createdAt
        releasedAt
      }
      pageInfo {
        startCursor
        endCursor
      }
    }
  }
}

Response:

{
  "data": {
    "project": {
      "releases": {
        "nodes": [
          {
            "createdAt": "2020-07-06T15:35:22Z",
            "releasedAt": "2020-07-06T15:35:22Z"
          },
          {
            "createdAt": "2020-07-09T19:20:06Z",
            "releasedAt": "2020-07-09T19:20:06Z"
          },
          {
            "createdAt": "2020-07-09T20:11:33Z",
            "releasedAt": "2020-07-09T20:11:33Z"
          }
        ],
        "pageInfo": {
          "startCursor": "eyJpZCI6IjEifQ",
          "endCursor": "eyJpZCI6IjMifQ"
        }
      }
    }
  }
}

Related to #26413 (closed)

Edited by Nathan Friend

Merge request reports

Loading