Skip to content

Switch to API v4 (GraphQL) #83

Closed
Closed

Description

@docwhat

The GitHub v4 (GraphQL) api is now official.

Since we're doing large queries across lots of objects in GitHub, using GraphQL will be significantly faster and use up less of the API Rate Limit.

Both reading and writing (mutating) are supported.

Activity

  1. added
    Type: Feature
    on Mar 29, 2018
  2. captn3m0 commented on Jan 28, 2019

    @captn3m0

    We hit our rate limits daily (150 Repos, 30 teams, and ~200 users in the org) and a lot of it is just because of plans fetching repos/teams/team memberships one by one.

    Switching to graphQL will help alleviate this significantly.

  3. deppy commented on Jul 30, 2019

    @deppy

    They're adding additional functionality into the graphQL/v4 api that isn't being added to v3. (traige and maintain permissions for example)

    @joebowbeer looks like repo creation has been added, didn't see a get-contents equivalent though.

  4. captn3m0 commented on Jul 30, 2019

    @captn3m0

    A simple GraphQL API based cache layer that is used while refreshing any resource will speed up operations by a lot. (One call to fetch a list of all repositories and then cache this for when a repository information is fetched.

    That way it could use both?

  5. patrickmarabeas commented on Jan 21, 2020

    @patrickmarabeas
    Contributor

    I've done a fair amount of work on a GraphQL version of the provider.

    The two major foundational pieces look to be:

    • Running REST and GraphQL clients side-by-side (including updating resources)
    • Updating all resources to use their Global Object ID (including writing state upgraders)

    This would then allow resources to be uplifted as required or when possible - the GraphQL API is still pretty barebones.

    I'll start to look at merging the work I've done back in.

  6. patrickmarabeas commented on Feb 10, 2020

    @patrickmarabeas
    Contributor

    The API surface for many of these is pretty different. Feedback would be good as to just how backwards compatible these need to be. In my opinion much of the data that was being returned was irrelevant within the context of Terraform.

    Addition of v4 client: https://github.com/terraform-providers/terraform-provider-github/pull/331

    Data sources:

    Resources:

    Resource IDs:

  7. julianvmodesto commented on Feb 10, 2020

    @julianvmodesto

    Would it be possible to select the API version for a resource, if v3 and v4 are supported?

    The v3 API has conditional requests, which allows for read requests to be cached, so it would be good to keep resources at v3 (at least the reads).

  8. kpfleming commented on Feb 10, 2020

    @kpfleming
    Contributor

    It is certainly possible; for example, in the OpenStack provider many resources have _v1, _v2, and _v3 flavors in order to accommodate users with different needs. This provider could provide _v4 flavors of the resources for users who want to upgrade.

  9. patrickmarabeas commented on Feb 16, 2020

    @patrickmarabeas
    Contributor

    What would the "upgrade" / "downgrade" path be between the different resources? State migration?

    Won't this be fairly painful with differences in IDs between the resources? At least when it's the same resource you can include an upgrade function which manages this stuff...

  10. patrickmarabeas commented on Feb 25, 2020

    @patrickmarabeas
    Contributor

    I would like to keep momentum on this work - who needs to be involved in deciding how this should proceed?

  11. patrickmarabeas commented on Feb 28, 2020

    @patrickmarabeas
    Contributor

    I've done some preliminary tests on handling the two different APIs using two separate providers. It seems to be the better choice.

    This way the resources themselves remain consistent and should allow for upgrade functions to work if we start v4 schema versions from say, v100, so there's no possible clash of a resource version between the two providers. Every version can have an update function - hopefully in both directions as well.

    provider "github" {
      organization = "myorg"
      ...
    }
    
    provider "github-v4" {
      organization = "myorg"
      ...
    }
    
    resource "github_branch_protection" "master" {
      provider = github-v4 # defaults to github
      ...
    }
    

    How does this sit with everyone?

  12. patrickmarabeas commented on Mar 10, 2020

    @patrickmarabeas
    Contributor
  13. docwhat commented on Mar 10, 2020

    @docwhat
    ContributorAuthor

    As long as resources all use GitHub's IDs to track objects, then switching between v3 and v4 should be easy. e.g. use repositoryId instead of the org/repo.

  14. 16 remaining items

  15. markediez commented on Feb 18, 2022

    @markediez

    Any news on this?

  16. astech-mweber3 commented on Oct 26, 2022

    @astech-mweber3

    Any news on this? This is really hitting us hard. It's really overdue that the provider utilizes the features introduced several years ago. Are there any plans on moving to the GraphQL API?

  17. kfcampbell commented on Oct 27, 2022

    @kfcampbell
    Contributor

    @spr-mweber3 are there particular resources you'd like to see the GraphQL API used in? We're using it in a number of places so far.

  18. astech-mweber3 commented on Oct 31, 2022

    @astech-mweber3

    @kfcampbell, yes sure. I'm particularly interested in having the resource github_repository_file implement that. Currently we're doing quite a lot with it and are hitting the rate limit quickly because every file is read/committed separately. It's just a waste of API calls the way this functionality is currently implemented in the provider.

  19. kfcampbell commented on Oct 31, 2022

    @kfcampbell
    Contributor

    Is that behavior you might be interested in submitting a PR to change?

  20. astech-mweber3 commented on Nov 14, 2022

    @astech-mweber3

    @nickfloyd @kfcampbell Sorry for the late response, guys. Unfortunately neither time nor skills provide that I fix this in a PR. Not my area of expertise (yet), but I'm happy to see that it already got picked up with high priority. 💯

    If I can be of any assistance in shaping the requirements of this feature or any other way, just let me know. I'd be really grateful if the github_repository_file resource would be a bit more thrifty in API calls. And I don't think I'm the only one.

  21. added
    Status: Up for grabs
    on Nov 15, 2022
  22. moved this to 🔥 Backlog in 🧰 Octokit Activeon Dec 5, 2022
  23. kfcampbell commented on Jan 5, 2023

    @kfcampbell
    Contributor

    @spr-mweber3 can I talk you into creating an issue for the particular resource(s) you want migrated over to the GraphQL API? I'd like to close this issue as-is, since we're not going to be doing a single PR to cut over every resource the GraphQL API would support.

  24. moved this from 🔥 Backlog to ✅ Done in 🧰 Octokit Activeon Jan 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ProviderStatus: Up for grabsType: Feature

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions