github icon indicating copy to clipboard operation
github copied to clipboard

Implement GitHub API server

Open iphydf opened this issue 8 years ago • 3 comments

I'd like to implement a caching GitHub API server (see https://github.com/TokTok/github-tools/issues/43) that is kept up to date via webhooks. This requires the GitHub types to be convertible back to JSON in a way that the result can be parsed again by GitHub API clients. Currently, there are FromJSON instances for all types, but no ToJSON ones.

Are there plans to support a transformation back to JSON?

iphydf avatar Jan 04 '17 14:01 iphydf

There are no plans. I haven't checked, but if the majority of FromJSON can be autoderived using tuned Options than making ToJSON would be possible, so at least clients using this library can benefit from such proxy.

Yet, if the consumer is also using this library, I'd recommend using Binary instances (we do that at work)

phadej avatar Jan 04 '17 16:01 phadej

https://github.com/TokTok/github-tools/blob/13e4a473d45084b9c9bf98e569d90d1eb2631086/web/GitHub/Types/Base/PullRequest.hs

Doing this helps a lot if you want to keep your data structure up to date with what's actually provided by the API. I have a webhook sitting on heroku that receives all the events from the toktok organisation. If github adds a field, I will know about it, because I produce json back out of the data structure and simply compare them for equality (modulo nulls).

iphydf avatar Jan 06 '17 17:01 iphydf

That's good philosophical question. How closely github package should follow GItHub api. From my (limited and non-automated maintainership) point-of-view adding fields on-need is more deliberate that trying to track GitHub api proactively. Especially as latter is made hard: have to reverse engineer and not e.g. parse some formalised spec. I'd happy to (love to!) do automation based on formalised (= machine readable) spec, but AFAIK there isn't one. See https://github.com/brendanhay/amazonka/blob/develop/gen/model/dynamodb/2012-08-10/service-2.json for example.

So I see the current way to proceed:

  • I'm happy to review PR updating / adding functionality
  • If someone can persuade GitHub formalising their API (declaratively) than we can change how this library is maintained.

phadej avatar Jan 06 '17 22:01 phadej