I'm doing a practice with this library https://www.npmjs.com/package/json-graphql-server, I'm just trying to have the correct queries to be able to make a crud from the frontend but I don't understand how to add a new post since it does not accept it as a parameter of the query variables. apparently it does not recognize the post parameter that I am sending it, but on the right side of the documentation I have put in that variable all the fields that are required
mutation addPst($post: PostInput!){
createPost(post: $post) {
title
}
}
Query variables:
{
"post": {
"id": "100",
"title": "Curso de GraphQL",
"views": 0,
"user_id": 123
}
}
Example: https://stackblitz.com/edit/json-graphql-server-nmctdj
Your mutation doesn't seem to be in line with the schema documentation you have posted.
The schema shows that the createPost mutation takes title, views and ID fields whereas you're passing in a "post" object.
Try rewriting the mutation as:
mutation addPst($title: String!, $views: Int!, $user_id: ID!){
createPost(title: $title, views: $views, user_id: $user_id) {
title
}
}