Skip to main content

Fetching data from the GitHub graphql API

Over the past few years, GitHub has been enabling developers to build on our platform as 3rd party integrators. This enablement does not come without limitations such as rate-limiting and token access. Open Sauced originally started as a way to try out the GitHub GraphQL API with a production-ready application.

Implementation approach

Open Sauced is exclusively powered by the public data from open source repos. Not only is the data drawn from open sourced repos, the onboarding flow for Open Sauced walks the user through creating their own open sourced repo in order to track their own contributions.

OneGraph

OneGraph is the tool used to consume the GitHub GraphQL API through one consistent GraphQL interface.

Persisted queries

Persisted queries are an advanced GraphQL feature that allow clients to pre-register queries with the server. In a typical workflow, the client will send the query to the server as part of a build process and the server will send back an id for the query. When the client wants to run the query, it sends the id instead of the full query string.

Developers use persisted queries because they reduce the amount of bandwidth sent from the client to the server and they improve security by locking down the queries that can be sent to the server.

OneGraph makes this all easy to do, and you can read up more on that in their documentation.

Goals repository

Each Open Sauced user leverages their own GitHub repository as a database. The repository is generated during sign up and is the companion for finding open source contributions to make. All data in this repository is a mirror of the data you see on the opensauced.pizza dashboard.

The repo open-sauced/goals-template is used as a template repo to generate the user's open-sauced-goals repo.

data.json The Open Sauced goal data in this list is populatated using the goals-caching.yml. Each opened issue in the goals repo full name is stored along with star, forks, and issues count. This is needed for rendering the user's open sauced dashboard.

stars.json The Open Sauced recommendation data is stored using the logged in user's starred repositories. This data is accessible via the GitHub API and stored publically in goals repo for easy rendering. The list is populatated using the goals-caching.yml. Plans are being developed to power platform wide recommendations using this data, this is pending the reviewing of the GitHub TOCs.

Use of API in components

The following table shows which components (src/components/*.js) use which API functions (src/lib/apiGraphQL.js', 'src/lib/persistedGraphQL.js), and what they do.

ComponentAPI FunctionPersisted/DynamicMutation
AddRepoFormapi.createGoal
Add goal through form input
Dynamicx
Contributionsapi.persistedInteractionsFetch
Contributions list for the user
Persisted
CreateGoalsapi.fetchOwnerId
Need the repo owner ID first
Dynamic
CreateGoalsapi.createOpenSaucedGoalsRepo
Create from template
Dynamicx
DangerZoneapi.updateGoal
Remove the goal
Dynamicx
Issuesapi.persistedIssuesByLabelFetch
Fetch Goal's issues labeled good first issue (First 5)
Persisted
Issuesapi.persistedIssuesFetch
Fetch Goal's all issues (First 5)
Persisted
Issuesapi.persistedRepositoryIssuesByLabelFetch
Fetch Goal's all issues (Paginated)
Persisted
Issuesapi.persistedRepositoryIssuesFetch
Fetch Goal's issues labeled good first issue (Paginated)
Persisted
NoteFormapi.updateGoal
Updates Notes
Dynamicx
RecommendedRepoListapi.createGoal
Add goal based on recommendations list
Dynamicx
Repositoryapi.persistedRepoDataFetch
Gather partial data for goal
Persisted
Repositoryapi.fetchGoalQuery
Gather partial data for goal
Dynamic
Repositoryapi.persistedForkFetch
Look at whether user has this repo forked
Persisted
Repositoryapi.persistedForkFetch
Initiate forking the repo for the user
Persisted
RepositoryGoalsapi.persistedViewerStars
Fetch repos starred by the user
Persisted
AdminStatsBarapi.fetchRateLimit
Shows administrator the status of rate limiting
Dynamic
AdminStatsBarapi.persistedDeploymentFetch
Shows administrator deployment status
Persisted
AdminStatsBarapi.fetchRepoCount
Shows administrator the user count, based on count of open-sauced-goals repos
Dynamic

References