Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/howtographql/graphql-ruby
GraphQL Ruby example for How To GraphQL
https://github.com/howtographql/graphql-ruby
graphql graphql-server rails ruby tutorial
Last synced: about 17 hours ago
JSON representation
GraphQL Ruby example for How To GraphQL
- Host: GitHub
- URL: https://github.com/howtographql/graphql-ruby
- Owner: howtographql
- License: mit
- Created: 2017-06-13T15:11:45.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-05-17T17:47:21.000Z (over 3 years ago)
- Last Synced: 2024-12-17T05:14:01.013Z (8 days ago)
- Topics: graphql, graphql-server, rails, ruby, tutorial
- Language: Ruby
- Homepage: https://www.howtographql.com/graphql-ruby/0-introduction/
- Size: 129 KB
- Stars: 264
- Watchers: 5
- Forks: 61
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# graphql-ruby
## Installation
Install dependencies:
```
bundle installrails db:setup
```Starting the server:
```
rails server
```Opening the application:
```
open http://localhost:3000/
```## Interesting Files:
- [GraphqlController](https://github.com/howtographql/graphql-ruby/blob/master/app/controllers/graphql_controller.rb) - GraphQL controller (api entry point)
- [GraphqlTutorialSchema](https://github.com/howtographql/graphql-ruby/blob/master/app/graphql/graphql_tutorial_schema.rb) - the schema definition
- [Mutations](https://github.com/howtographql/graphql-ruby/blob/master/app/graphql/types/mutation_type.rb) - root mutations
- [Queries](https://github.com/howtographql/graphql-ruby/blob/master/app/graphql/types/query_type.rb) - root queries
- [UserType](https://github.com/howtographql/graphql-ruby/blob/master/app/graphql/types/user_type.rb) - record type
- [VoteType](https://github.com/howtographql/graphql-ruby/blob/master/app/graphql/types/vote_type.rb) - record type
- [LinkType](https://github.com/howtographql/graphql-ruby/blob/master/app/graphql/types/link_type.rb) - record type
- [DateTimeType](https://github.com/howtographql/graphql-ruby/blob/master/app/graphql/types/date_time_type.rb) - scalar type
- [LinksSearch](https://github.com/howtographql/graphql-ruby/blob/master/app/graphql/resolvers/links_search.rb) - complex search resolver and its [tests](https://github.com/howtographql/graphql-ruby/blob/master/test/graphql/resolvers/links_search_test.rb)
- [CreateLink](https://github.com/howtographql/graphql-ruby/blob/master/app/graphql/mutations/create_link.rb) - mutation and its [tests](https://github.com/howtographql/graphql-ruby/blob/master/test/graphql/mutations/create_link_test.rb)
- [CreateUser](https://github.com/howtographql/graphql-ruby/blob/master/app/graphql/mutations/create_user.rb) - mutation and its [tests](https://github.com/howtographql/graphql-ruby/blob/master/test/graphql/mutations/create_user_test.rb)
- [CreateVote](https://github.com/howtographql/graphql-ruby/blob/master/app/graphql/mutations/create_vote.rb) - mutation and its [tests](https://github.com/howtographql/graphql-ruby/blob/master/test/graphql/mutations/create_vote_test.rb)
- [SignInUser](https://github.com/howtographql/graphql-ruby/blob/master/app/graphql/mutations/sign_in_user.rb) - mutation and its [tests](https://github.com/howtographql/graphql-ruby/blob/master/test/graphql/mutations/sign_in_user_test.rb)## 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
name
}
}
```Creates new user token:
```graphql
mutation {
signinUser(credentials: {email: "[email protected]", password: "123456"}) {
token
user {
id
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
}
}
}
```