• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

github/github-graphql-rails-example: Example Rails app using GitHub's GraphQ ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

github/github-graphql-rails-example

开源软件地址(OpenSource Url):

https://github.com/github/github-graphql-rails-example

开源编程语言(OpenSource Language):

Ruby 47.7%

开源软件介绍(OpenSource 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




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
apollographql/xcode-graphql: 发布时间:2022-06-13
下一篇:
octokit/graphql-schema: GitHub’s GraphQL Schema with validation. Automatically ...发布时间:2022-06-13
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap