I'm doing a practice with this library
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
CodePudding user response:
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
}
}