Coder Social home page Coder Social logo

iq-scm / github-graphql-rails-example Goto Github PK

View Code? Open in Web Editor NEW

This project forked from github/github-graphql-rails-example

0.0 0.0 0.0 236 KB

Example Rails app using GitHub's GraphQL API

License: MIT License

JavaScript 4.41% Ruby 47.70% CSS 4.30% HTML 43.58%

github-graphql-rails-example's Introduction

GitHub GraphQL Rails example application

Demonstrates how to use the graphql-client gem to build a simple repository listing web view against the GitHub 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.

Table of Contents

Jump right into the code and read the inline documentation. The following is a suggested reading order:

  1. app/controller/repositories_controller.rb defines the top level GraphQL queries to fetch repository list and show pages.
  2. app/views/repositories/index.html.erb shows the root template's listing query and composition over subviews.
  3. app/views/repositories/_repositories.html.erb makes use of GraphQL connections to show the first couple items and a "load more" button.
  4. app/views/repositories/show.html.erb shows the root template for the repository show page.
  5. app/controller/application_controller.rb defines controller helpers for executing GraphQL query requests.
  6. config/application.rb configures GraphQL::Client to point to the GitHub GraphQL endpoint.

Running locally

First, you'll need a GitHub API access token to make GraphQL API requests. This should be set as a GITHUB_ACCESS_TOKEN environment variable as configured in config/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 visit http://localhost:3000/.

See Also

github-graphql-rails-example's People

Contributors

josh avatar krider2010 avatar mikrobi avatar nakajima avatar nickvanw avatar oguzbilgic avatar sebamelgar avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.