百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
G

graphql-ruby

> 后端框架
开源

GraphQL Ruby 示例,来自 How To GraphQL

266 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

GraphQL Ruby 示例,来自 How To GraphQL

graphql-ruby

Installation

Install dependencies:

bundle install

rails db:setup

Starting the server:

rails server

Opening the application:

open http://localhost:3000/

Interesting Files:

  • GraphqlController - GraphQL controller (api entry point)
  • GraphqlTutorialSchema - the schema definition
  • Mutations - root mutations
  • Queries - root queries
  • UserType - record type
  • VoteType - record type
  • LinkType - record type
  • DateTimeType - scalar type
  • LinksSearch - complex search resolver and its tests
  • CreateLink - mutation and its tests
  • CreateUser - mutation and its tests
  • CreateVote - mutation and its tests
  • SignInUser - mutation and its tests

Sample GraphQL Queries

List first 10 links, containing "example":

graphql
{
  allLinks(first: 10, filter: {descriptionContains: "example"}) {
    id
    url
    description
    createdAt
    postedBy {
      id
      name
    }
  }
}

Creates new user:

graphql
mutation {
  createUser(
    name: "Radoslav Stankov",
    authProvider: {
      credentials: { email: "[email protected]", password: "123456" }
    }
  ) {
    id
    email
    name
  }
}

Creates new user token:

graphql
mutation {
  signinUser(credentials: {email: "[email protected]", password: "123456"}) {
    token
    user {
      id
      email
      name
    }
  }
}

Creates new link:

graphql
mutation {
  createLink(url:"http://example.com", description:"Example") {
    id
    url
    description
    postedBy {
      id
      name
    }
  }
}

Creates new vote:

graphql
mutation {
  createVote(linkId:"TGluay0yMQ==") {
    user {
      id
      name
    }
    link {
      id
      url
      description
    }
  }
}

Issues· 4 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Rubygraphqlgraphql-serverrailsruby

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类后端框架
定价开源

> 相关工具

N
Node.js
基于 V8 的 JavaScript 运行时
D
Django
Python 高级 Web 框架
S
Spring Boot
Java 生态主流微服务框架