Something goes "horribly, horribly wrong" with inline fragments on pagination


#1

Using the following query in the explorer causes “something, somewhere, [to go] horribly, horribly wrong”:

query TestQuery {
  repository(owner:"mathstuf", name:"rust-keyutils") {
    pullRequest(number:7) {
    timeline(first:100) {
      ... on PullRequestTimelineConnection {
        pageInfo {
          endCursor
        }
      }
    }
    }
  }
}

#2

The error I get when I try to run this query is

{
  "data": null,
  "errors": [
    {
      "message": "Field 'timeline' doesn't exist on type 'Repository'",
      "locations": [
        {
          "line": 3,
          "column": 5
        }
      ]
    }
  ]
}

I think you need to first get a pull request or an issue to look at the timeline.


#3

Gah, that’s what I get for hand copying from one machine to another. Will edit the original post.


#4

Ah, okay. Since the type of timeline here is PullRequestTimelineConnection, you don’t need ... on PullRequestTimelineConnection.

query TestQuery {
  repository(owner: "mathstuf", name: "rust-keyutils") {
    pullRequest(number: 7) {
      timeline(first: 100) {
        pageInfo {
          endCursor
        }
      }
    }
  }
}

If you want to get further data, you can take a look at the types you get back by doing

query TestQuery {
  repository(owner: "mathstuf", name: "rust-keyutils") {
    pullRequest(number: 7) {
      timeline(first: 100) {
        edges {
          node {
            __typename
          }
        }
        pageInfo {
          endCursor
        }
      }
    }
  }
}

and then get information about the different types that are returned by doing e.g.

query TestQuery {
  repository(owner: "mathstuf", name: "rust-keyutils") {
    pullRequest(number: 7) {
      timeline(first: 100) {
        edges {
          node {
            ... on CrossReferencedEvent {
              createdAt
            }
            ... on HeadRefForcePushedEvent {
              createdAt
            }
          }
        }
        pageInfo {
          endCursor
        }
      }
    }
  }
}

using any of the types mentioned in the documentation for PullRequestTimelineItem.

However, that said, this should totally not cause a horribly, horribly wrong error! We’ve opened an internal issue for fixing that.


#5

Thanks!