``` client.mutate(` createPerson ( nam...
# prisma-whats-new
s
Copy code
client.mutate(`
    createPerson (
        name: "Sindre Svendby"
    ) {
      id
      name
 }`).then(data => console.log('ok', data)
.then(err => console.log('err', err)
The result is
ok undefined
because I had forgotten the starting and ending brackets
{}
around.... but should not the server send back and error if it is not able to parse my request? Is this according to spec and the way people think it should behave?
n
hey @Sindre Svendby could you provide more information? what is
client
?
and where are you running this code?
a
If this is Apollo client, the
catch
does not fire, because the response has a http status 200. You need to handle this inside the
.then
, not inside the
.catch
s
Sorry, the client is Lokka, so a complete example is:
Copy code
const Lokka = require("lokka").Lokka;
const Transport = require("lokka-transport-http").Transport;

const headers = {
  Authorization: process.env.TOKEN // 'Bearer YOUR_AUTH_TOKEN'
};

const client = new Lokka({
  transport: new Transport(process.env.GRAPHQL_SERVER, { headers })
});

client
  .mutate(
    `
  createPerson (
    name: "Sindre Svendby"
  ) {
    name
  }
`
  )
  .then(data => console.log("ok", data))
  .catch(err => console.log("err", err));
and GRAPHQL_SERVER is a graphcool endpoint. This does not return and error, but does not work either. Not sure if this is the client
Lokka
or the graphcool server, but for me I would expect it to say that it could not parse my request, and throw and error. I'm using Lokka, since I just are doing basic stuff in one file and I got a working example from the graphcool playground!
n
I would recommend using
graphql-request
instead 🙂
❤️ 1
👍🏻 1
s
ok, thx, will start using that! Awesome stuff you are doing btw! Keep up the good work!
💚 1