Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider support for Schema Previews. #34

Open
dmitshur opened this issue Apr 26, 2018 · 8 comments
Open

Consider support for Schema Previews. #34

dmitshur opened this issue Apr 26, 2018 · 8 comments
Labels
API decision enhancement NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. thinking

Comments

@dmitshur
Copy link
Member

dmitshur commented Apr 26, 2018

Similar to GitHub REST API v3, GitHub GraphQL API v4 also has preview APIs that let users try out new features and changes before they become part of the official GitHub API:

https://developer.github.com/v4/previews/

One of the core focuses of this library is:

  • Support all of GitHub GraphQL API v4 via code generation from schema.

There are two relevant parts. One, we might want to support the preview APIs, since they're in a way a part of the API. Two, we want to try to do this in an automated way, rather than manually.

Finding a way to support these without in an automated way is very important, because otherwise, this could create a very significant amount of manual work (compared to the work required to develop and maintain the rest of this library).

@dmitshur dmitshur added enhancement API decision thinking NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Apr 26, 2018
@dmitshur
Copy link
Member Author

dmitshur commented Apr 26, 2018

Since this library is largely generated, a viable possibility to consider is creating a separate package that includes support for the schema previews (doing this isn't as viable in go-github because that library is mostly written by hand).

I just want to point that out, but whether or not it's a good idea to split off preview functionality into a different package (e.g., githubv4preview) will need to be determined when investigating this issue. It might not be a good idea.

@ItsMeWithTheFace
Copy link

Hey @dmitshur! Are there any updates on this issue?

@dmitshur
Copy link
Member Author

dmitshur commented Jun 27, 2019

There are no updates on this from my side yet, but there is some new demand for this feature (see #44). I won't have time to work on this in the short term.

If you need this implemented, my recommendation is to experiment with finding a good solution in a fork. It will be helpful if you report your findings in this issue, so that it can eventually be upstreamed. Thank you!

@christophermancini
Copy link

We encountered this issue while working on a PR / Fork for the Concourse github-pr-resource. Our internal GHE appliance is currently on 2.16 and we are experimenting with features that are behind the preview Accept header... :(

@AlekSi
Copy link

AlekSi commented May 8, 2020

@gleich
Copy link

gleich commented Sep 2, 2020

Any update on this?

@caquino
Copy link

caquino commented Jan 28, 2022

Hi, I see we have other issues/prs/forks to solve this issue but I'm curious if we had any progress on a official way to handle schema previews, I have no issues with any of the options but as the discussion has been going for a while I wanted to try to get any updates before working on something that feels like a "workaround".

@ashleydavies
Copy link

ashleydavies commented Jul 28, 2023

For future readers, I ended up doing this, which seems to be a functioning work-around:

type headerInjector struct {
	base http.RoundTripper
}

func (h *headerInjector) RoundTrip(req *http.Request) (*http.Response, error) {
	req.Header.Add("Accept", "application/vnd.github.merge-info-preview+json")
	return h.base.RoundTrip(req)
}

token := &TokenSource{
	AccessToken: "My OAuth token",
}

...

oauthClient := oauth2.NewClient(context.Background(), token)
oauthClient.Transport = &headerInjector{
	base: oauthClient.Transport,
}

ghQlClient := githubql.NewClient(
	oauthClient,
)

Parameterising the header injector on the previews you are interested in is left as an exercise to the reader 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API decision enhancement NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. thinking
Development

No branches or pull requests

7 participants