mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 20:54:07 -08:00
✨ Add header authentication to GraphQL node (#1805)
This commit is contained in:
parent
7ccc0f40a2
commit
d3aa637ff4
|
@ -25,7 +25,37 @@ export class GraphQL implements INodeType {
|
||||||
},
|
},
|
||||||
inputs: ['main'],
|
inputs: ['main'],
|
||||||
outputs: ['main'],
|
outputs: ['main'],
|
||||||
|
credentials: [
|
||||||
|
{
|
||||||
|
name: 'httpHeaderAuth',
|
||||||
|
required: true,
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
authentication: [
|
||||||
|
'headerAuth',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
properties: [
|
properties: [
|
||||||
|
{
|
||||||
|
displayName: 'Authentication',
|
||||||
|
name: 'authentication',
|
||||||
|
type: 'options',
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: 'Header Auth',
|
||||||
|
value: 'headerAuth',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'None',
|
||||||
|
value: 'none',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
default: 'none',
|
||||||
|
description: 'The way to authenticate.',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
displayName: 'HTTP Request Method',
|
displayName: 'HTTP Request Method',
|
||||||
name: 'requestMethod',
|
name: 'requestMethod',
|
||||||
|
@ -200,6 +230,7 @@ export class GraphQL implements INodeType {
|
||||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||||
|
|
||||||
const items = this.getInputData();
|
const items = this.getInputData();
|
||||||
|
const httpHeaderAuth = this.getCredentials('httpHeaderAuth');
|
||||||
|
|
||||||
let requestOptions: OptionsWithUri & RequestPromiseOptions;
|
let requestOptions: OptionsWithUri & RequestPromiseOptions;
|
||||||
|
|
||||||
|
@ -228,6 +259,11 @@ export class GraphQL implements INodeType {
|
||||||
rejectUnauthorized: !this.getNodeParameter('allowUnauthorizedCerts', itemIndex, false) as boolean,
|
rejectUnauthorized: !this.getNodeParameter('allowUnauthorizedCerts', itemIndex, false) as boolean,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Add credentials if any are set
|
||||||
|
if (httpHeaderAuth !== undefined) {
|
||||||
|
requestOptions.headers![httpHeaderAuth.name as string] = httpHeaderAuth.value;
|
||||||
|
}
|
||||||
|
|
||||||
const gqlQuery = this.getNodeParameter('query', itemIndex, '') as string;
|
const gqlQuery = this.getNodeParameter('query', itemIndex, '') as string;
|
||||||
if (requestMethod === 'GET') {
|
if (requestMethod === 'GET') {
|
||||||
requestOptions.qs = {
|
requestOptions.qs = {
|
||||||
|
|
Loading…
Reference in a new issue