I am attempting to create a config node similar to this example, but it only displays a text box and not the configuration options. I want the projectid to be a config node, and despite trying various nodes with config setups, nothing seems to work for me. How can I resolve this issue?
graphql_query.js
module.exports = function(RED) {
function netpie_graphql_query(nodeConfig) {
RED.nodes.createNode(this,nodeConfig);
var node = this;
node.on('input', function(msg) {
var gqlquery = nodeConfig.gqlquery;
nodeConfig.projectid = RED.nodes.getNode(nodeConfig.projectid).projectid;
const axios = require('axios');
let data = JSON.stringify({
query: gqlquery,
variables: {}
});
let axiosConfig = {
method: 'post',
maxBodyLength: Infinity,
url: 'http://gqlv2.aaaaa.io/',
headers: {
'Authorization': 'bearer '+auth.token,
'Content-Type': 'application/json'
},
data : data
};
axios.request(axiosConfig)
.then((response) => {
data = (JSON.stringify(response.data));
msg.payload = data;
node.send(msg);
})
.catch((error) => {
//console.log(error);
this.error("Request failed with status code 400, please check your schema");
});
});
}
RED.nodes.registerType("netpie_graphql_query",netpie_graphql_query);
}
graphql_query.html
RED.nodes.registerType('netpie_graphql_query',{
category: 'graphql',
color:'#00adff',
defaults:{
projectid:{value:"", type:"projectid"},
name:{value:""},
gqlquery:{value:""}
},
inputs:1,
outputs:1,
icon:"template.svg",
label:function(){
return this.name||"netpie graphql";
},
oneditprepare: function() {
this.editor = RED.editor.createEditor({
id: 'gqlquery-message-editor',
mode: 'ace/mode/text',
value: $("#node-input-gqlquery").val()
});
},
oneditsave: function() {
$("#node-input-gqlquery").val(this.editor.getValue());
this.editor.destroy();
delete this.editor;
},
oneditcancel: function() {
this.editor.destroy();
delete this.editor;
}
});
</script>
<script type="text/html" data-template-name="netpie_graphql_query">
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i>Name</label>
<input type = "text" id="node-input-name" placeholder="Name">
</div>
...
but projectid is not config node https://i.sstatic.net/cwbLB.png