Each tutorial step is broken down in this repo's commit history
- Getting Started
- Queries
- Mutations
- Authentication
- Connecting Nodes
- Error Handling
- Filtering
- Pagination
- Summary
Install dependencies:
bundle install
rails db:setup
Starting the server:
rails server
Opening the application:
open http://localhost:3000/
- 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
List first 5 links containing "watch":
{
searchLinks(
first: 5,
skip: 0,
filter:{
descriptionContains: "watch"
}
) {
url
description
postedBy {
name
}
}
}
Creates new user:
mutation {
createUser(
name: "Testy McTester",
authProvider: {
credentials: {
email: "[email protected]",
password: "password"
}
}
) {
email
id
name
}
}
Creates new user token:
mutation {
loginUser(
credentials: {
email: "[email protected]",
password: "password"
}
) {
token
user {
name
}
}
}
Creates new link:
mutation {
createLink(
description: "Watch NHL 🏒",
url: "http://nhl.com"
) {
description
url
id
postedBy {
id
}
}
}
Creates new vote:
mutation {
createVote(
linkId: "4"
) {
link {
description
url
}
}
}
Get all links and votes, with the voter and their vote history:
{
allLinks {
url
description
id
votes {
user {
name
votes {
link {
url
description
id
}
}
}
}
}
}