Repository navigation
refactor(platform): Share the GitHub REST headers and GraphQL envelope through platform/githubapi - #1012
Draft
roychying wants to merge 1 commit into
Draft
refactor(platform): Share the GitHub REST headers and GraphQL envelope through platform/githubapi#1012roychying wants to merge 1 commit into
roychying wants to merge 1 commit into
Conversation
…e through platform/githubapi instead of repeating them in each GitHub caller
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why?
Five callers of the GitHub API each repeat the same request plumbing. The REST callers copy the same three headers and their own pin of the API version, so a version bump has to find every copy. The two GraphQL callers each define their own request, response and error types and their own send-and-decode code, and the copies have already drifted: one calls
client.Dodirectly, the other goes throughplatform/http.SendRequest.The endpoint methods stay with each caller: no endpoint has two callers, each reads statuses its own way, and one GraphQL query per caller keeps its GitHub App permissions minimal. An endpoint group can be moved to
platformwhen a second extension calls it.What?
platform/githubapi:SetRESTHeaderssets the JSON media type and pins the REST API version in oneVersionconstant.QueryGraphQLposts aGraphQLRequestto/graphqland decodesdatainto the caller's type. A non-200 reply is aplatform/http.StatusError, soplatform/errs/httpclassifies it as before. A 200 reply with GraphQL errors fails even when it also carries data.*http.Clientand typed requests.platform/githubactions,runway/extension/merger/githubandtest/testutil/githubtestrepo(REST), andsubmitqueue/extension/changeprovider/githubandsubmitqueue/extension/validator/github(GraphQL).GraphQL errors: TYPE: message; …instead of a struct dump.Test Plan
bazel test //platform/githubapi/... //platform/githubactions/... //runway/extension/merger/github/... //submitqueue/extension/changeprovider/github/... //submitqueue/extension/validator/github/... //submitqueue/extension/buildrunner/githubactions/... //stovepipe/extension/buildrunner/githubactions/...Issue