Githawk: Fetch notification issue/PR status

Created on 30 Dec 2017  路  7Comments  路  Source: GitHawkApp/GitHawk

Had a 馃挕 moment w/ @orta this morning. We can request _multiple issue/PR_ status info via the GraphQL API to batch notification status into a single network request using GQL aliases. An example request:

query {
  repository(owner: "rnystrom", name: "githawk") {
    issue(number:1) {
      title
      state
    }
    issue2: issue(number:2) {
      title
      state
    }
  }
}

Response:

{
  "data": {
    "repository": {
      "issue": {
        "title": "Sample issue",
        "state": "CLOSED"
      },
      "issue2": {
        "title": "New MarkdownView",
        "state": "CLOSED"
      }
    }
  }
}

The trick to making this work is to:

  1. Fetch notifications w/ V3 API

    • Mark all models as status "pending" or something, show as blue

  2. Collect all issue/PR numbers
  3. Dynamically build a GraphQL request

    • Do not use Apollo for this

  4. Send request w/ token, manually parse
  5. Map status and update models
  6. Refresh UI

    • Updates should be done via FlatCache, so just reload feed with .list type changes

Really, really excited about this. Makes consuming notifications so much easier!

馃啎 feature request

All 7 comments

I know you said not to use Apollo, but might be an idea to throw this Martijn as it could be pretty cool functionality on their side to group requests! (extremely powerful, and something they could do pretty easily with their infra!)

Overall support the idea

Good call, creating dynamic queries would be _amazing_.

Cc @martijnwalraven :)

Sent with GitHawk

We've experimented with various ways of doing query batching in Apollo Client, including dynamically constructing queries. Using dynamic queries had too many drawbacks however, so we've actually removed this from more recent versions. Instead, we recommend transport level batching, which is a simple way to send multiple queries in a single HTTP request. It does require server support however, so it may not be supported by the GitHub API.

Btw got a hack together locally! Going to add comment count as well as change the icon depending on status (there's a closed-issue icon).

simulator screen shot - iphone x - 2018-01-03 at 17 27 21

Yesssss! Would it be possible to query for labels also (and show them, just like in repositories)? That would be perfect!

Sent with GitHawk

@BasThomas yup! that's a good followup. I added a comment count too (not sold on its position atm). Honestly this unlocks so many doors!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

weyert picture weyert  路  3Comments

rnystrom picture rnystrom  路  3Comments

BasThomas picture BasThomas  路  3Comments

rnystrom picture rnystrom  路  3Comments

BasThomas picture BasThomas  路  3Comments