-1

I am trying to create a mutation to insert an entry into the project query, but the response for the mutation is null. When I run the project query after the mutation, I see the same data as before, but not the updated data. How do I fix it?

project query (Request):

{
  project(id:"1") {
    issues {
      id,
      title,
      description
    }
  }
}

project query (Response):

{
  "data": {
    "project": {
      "issues": [
        {
          "id": "1",
          "title": "Issue One",
          "description": ""
        },
        {
          "id": "2",
          "title": "Issue Two",
          "description": ""
        },
        {
          "id": "4",
          "title": "Issue Four",
          "description": "This is issue 4"
        }
      ]
    }
  }
}

Mutation to add an entry to the Project:

mutation {
  createIssue(input: {
    projectId: "1",
    title: "My Issue",
    description: "Missing Issue",
    clientMutationId: "1234"
  }) {
    clientMutationId,
    issue {
      description,
      id,
      title
    }
  }
}

Response:

{
  "data": {
    "createIssue": null
  }
}
Jake
  • 25,479
  • 31
  • 107
  • 168
  • it depends on what is inside `createIssue` resolver, can you share that? – Besufkad Menji Sep 25 '20 at 02:58
  • I have not designed a resolver. New to GraphQL.. createIssue has the same types as mentioned in the request. I wasn't sure how to write a resolver in GraphQL – Jake Sep 25 '20 at 03:03
  • you should contact the developer who created the resolver because the resolver is the one responsible for returning a data after performing some tasks, nothing can be done from frontend only – Besufkad Menji Sep 25 '20 at 03:08
  • I will rephrase the question and update it. I am doing this solely in GraphQL only and no JS is involved.. Just trying to come up with a method to insert a missing entry. – Jake Sep 25 '20 at 03:14
  • Just updated it... – Jake Sep 25 '20 at 03:23
  • ... and your 'project response' appears magically without js involved? ... in dreams ... wake up ... quer/mutation is only a command/request for engine to be processed ... resolver returns existing or creates new data – xadm Sep 25 '20 at 03:34
  • I have been using `GraphiQL`, which is an browser based GraphQL validator. – Jake Sep 25 '20 at 03:36
  • 1
    it's not a validator, it's a 'graphql client' ... client talking to server/API ... node.js/apollo server responds to requests using resolvers ... your (or not your if you're not responsible for backend) resolver returns response, what is returned depends fully on ... resolver ... check API docs/ask resolver author why it doesn't work for this query/mutation – xadm Sep 25 '20 at 03:58

1 Answers1

1

the issue is not from you, to explain this on a simplified way: on the backend createIssue and issues are handled by different functions(resolvers), which means as API consumer you can do nothing to change what their response is. check if you graphQL query and mutation are valid (GraphQL IDE- you can use this tool) and if they are the problem is from the backend

Besufkad Menji
  • 1,433
  • 9
  • 13