- Notifications
You must be signed in to change notification settings - Fork50
Example Rails app using GitHub's GraphQL API
License
github/github-graphql-rails-example
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Demonstrates how to use thegraphql-client
gem to build a simple repository listing web view against theGitHub GraphQL API.
The application structure is setup like a typical Rails app using controllers, views and routes with one key difference, no models. This app doesn't connect directly to any database. All the data is being fetched remotely from the GitHub GraphQL API. Instead of declaring resource models, data queries are declared right along side their usage in controllers and views. This allows an efficient single request to be constructed rather than making numerous REST requests to render a single view.
Jump right into the code and read the inline documentation. The following is a suggested reading order:
- app/controller/repositories_controller.rb defines the top level GraphQL queries to fetch repository list and show pages.
- app/views/repositories/index.html.erb shows the root template's listing query and composition over subviews.
- app/views/repositories/_repositories.html.erb makes use of GraphQL connections to show the first couple items and a "load more" button.
- app/views/repositories/show.html.erb shows the root template for the repository show page.
- app/controller/application_controller.rb defines controller helpers for executing GraphQL query requests.
- config/application.rb configures
GraphQL::Client
to point to the GitHub GraphQL endpoint.
First, you'll need aGitHub API access token to make GraphQL API requests. This should be set as aGITHUB_ACCESS_TOKEN
environment variable as configured inconfig/secrets.yml.
$ git clone https://github.com/github/github-graphql-rails-example$cd github-graphql-rails-example/$ bundle install$ GITHUB_ACCESS_TOKEN=abc123 bin/rails server
And visithttp://localhost:3000/.
About
Example Rails app using GitHub's GraphQL API
Resources
License
Code of conduct
Security policy
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.