Run the commands below.
$ git clone https://github.com/K-Sato1995/GraphqlApi.git
$ bundle install
$ rake db:migrate
Run rails s
and send following queries and mutations.
{
posts {
id
title
description
comments
}
}
This is just an example. Check out Ransack's README for more search Matchers.
{
posts(q: { status_eq: "PUBLISHED" }) {
id
title
description
status
comments {
id
}
}
}
{
post(id: 1) {
id
title
description
comments {
id
content
}
}
}
mutation {
createPost(input: { title: "title1", description: "description1" }) {
post {
id
title
description
}
}
}
mutation {
updatePost(input: { id: 1, title: "Updated", description: "UPdated" }) {
post {
id
title
description
}
}
}
mutation {
deletePost(input: { id: 1 }) {
post {
id
title
description
}
}
}
mutation {
createComment(input: { postId: 3, content: "NEW COMMENT" }) {
comment {
id
content
post {
id
title
comments {
id
content
}
}
}
}
}
mutation {
createUser(
input: {
name: "title1"
authProvider: { email: { email: "[email protected]", password: "passsssord" } }
}
) {
user {
id
name
email
}
}
}
mutation {
signinUser(
input: { email: { email: "[email protected]", password: "passsssord" } }
) {
token
}
}
{
posts {
id
title
description
status
mediaItem {
__typename
... on AudioClip {
id
duration
}
... on VideoClip {
id
previewUrl
resolution
}
}
comments {
id
content
}
}
}
The front end of this api buit in TypeScript.