GitHub GraphQL API Client - I'm struggling - is this even doable?

Hi,

I’ve posted a couple of times already and I’m really struggling to achieve what I want - more that I ever have with any other framework. I’ve read the documentation over and over, spent ages on the forum and stackoverflow and spent quite a lot of time playing. I’ve got the browser tooling setup, I can see what’s in my cache, but I cannot figure out sorting, counts or filtering.

I thought I’d post what I’m trying to do and just ask whether I’m trying to push apollo client too far?

The concept

I want to build a small dashboard against the GitHub API to help with triaging and maintaining across 100s of repositories.

What I’m trying to achieve:

  • list repos ordered by number of open PRs
  • show how many PRs are from renovate (and ideally have the option to sort by that number too)
  • show how many PRs are from non-org members (again with sort option)
  • show how many issues are from non-org members (again, sort would be great)
  • filter to show certain groups of repositories, e.g. by a topic, or just a fixed list
  • show other complex data about repositories like the node version set in package.json, or if certain workflows are configured or if renovate is not configured

All of this data is available via the GraphQL API, but the API is nested with “Connections”.

I’ve got basic pagination working by writing my own merge function, but I can’t sort or filter because once I get to a connection, I cannot access that data inside a read or merge function.

Can Apollo Client do this?

I don’t have control over the server or the schema. I want a client to show and use data that comes from different connections e.g. repositories → pullRequests and repositories → repositoryTopics.

I want to manipulate the data slightly to achieve extra counts and sorting. I also want to be able to filter, but the filters I want to use are not available as queries on the GraphQL API.

Thanks for any help or advice.


My code so far is here: GitHub - TryGhost/slimer-dashboard: GitHub Dashboard built in Apollo

1 Like

I personally wouldn’t try to do this at the apollo client cache level, I think I would just sort/filter the data after I get it back from apollo client. It probably is possible but I don’t have quite enough knowledge to make something like that work :frowning: sorry

Fair enough. I did this before and it quickly became a mess, and I felt certain that with AC3 there had to be a better way.

I appreciate your answer on my other thread about sorting. The reality is I spent hours searching for how to do that with readField as I was certain it had to be possible. But I also gave up and did the sort in JS which took me like 30seconds.

I love the concept of Apollo, it’s such a cool idea and the client + cache combo seems so powerful, but I’m feeling very frustrated because it seems like AC3 should be able to do more than I’m able to get it to do.

It’s been a very long time since something written in JS managed to baffle me this hard.

1 Like