Sindre Svendby
09/29/2017, 3:02 AMclient.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?nilan
09/29/2017, 8:32 AMclient
?nilan
09/29/2017, 8:32 AMagartha
09/29/2017, 9:48 AMcatch
does not fire, because the response has a http status 200. You need to handle this inside the .then
, not inside the .catch
Sindre Svendby
09/29/2017, 4:18 PMconst 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!nilan
09/29/2017, 4:39 PMgraphql-request
instead 🙂nilan
09/29/2017, 4:40 PMSindre Svendby
09/29/2017, 4:54 PM