Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ A NodeRed node to execute GraphQL Queries.

| Vers | Changes |
| ----- | -------------------------------------------------------- |
| 2.1.3 | Fix payload not init on error case; Fix payload not overwriting primitives (#50) |
| 2.1.2 | Fix payload init issue |
| 2.1.0 | Bearer Token Authentication |
| 2.0.1 | Update dependencies (`axios` & `mustache`), fix node-red scorecard issues |
Expand Down
6 changes: 4 additions & 2 deletions graphql.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ module.exports = function(RED) {
// https://github.com/axios/axios
var axios = require("axios");
var mustache = require("mustache");
var isPlainObject = require("lodash.isplainobject");

var vers = "2.1.2";
var vers = "2.1.3";

function isReadable(value) {
return typeof value === 'object' && typeof value._read === 'function' && typeof value._readableState === 'object'
Expand Down Expand Up @@ -151,7 +152,7 @@ module.exports = function(RED) {
shape: "dot",
text: RED._("graphql.status.success")
});
if (!node.msg.payload) node.msg.payload = {};
if (!isPlainObject(node.msg.payload)) node.msg.payload = {};
node.msg.payload.graphql = response.data.data; // remove .data to see entire response
if (node.showDebug){
node.msg.debugInfo = {
Expand Down Expand Up @@ -189,6 +190,7 @@ module.exports = function(RED) {
.catch(function(error) {
RED.log.debug("error:" + error);
node.status({ fill: "red", shape: "dot", text: "error" });
if (!isPlainObject(node.msg.payload)) node.msg.payload = {};
node.msg.payload.graphql = { error };
node.error("error: " + error);
node.send([null, node.msg]);
Expand Down
Loading