f / graphql.js

A Simple and Isomorphic GraphQL Client for JavaScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error with mutation that returns true

alxx opened this issue · comments

I can't understand what I'm doing wrong, but all mutations calls fail with this error in the browser console:

Uncaught TypeError: that [m.method] (...) is not a function
at GraphQLClient.that.(/Users/.../anonymous function).run (file:///Users/.../vendor/graphql.min.js:1:8351)
at deleteAuthor (app.js:82)
at HTMLButtonElement. (app.js:15)
at HTMLButtonElement.dispatch (jquery.min.js:2)
at HTMLButtonElement.y.handle (jquery.min.js:2)
that.(anonymous function).run @ graphql.min.js:1
deleteAuthor @ app.js:82
(anonymous) @ app.js:15
dispatch @ jquery.min.js:2
y.handle @ jquery.min.js:2

Here's how I run the migration:

var q = `DeleteAuthor($id: ID) {DeleteAuthor(id: $id)}`;
var vars = {id: id};

graph.mutate.run(q, vars).then(function (r) {
    alert(`Author ${id} deleted.`);
}).catch(function (error) {
    alert(JSON.stringify(error))
})

I'm trying this in Chrome 66. Any ideas?

Apparently it was because I forgot the "mutation" keyword at the beginning of the query.