-
Notifications
You must be signed in to change notification settings - Fork 8.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(GraphQL Node): Fix request format JSON error (#8646)
- Loading branch information
Showing
4 changed files
with
108 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
packages/nodes-base/nodes/GraphQL/test/GraphQL.node.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import type { WorkflowTestData } from '@test/nodes/types'; | ||
import { executeWorkflow } from '@test/nodes/ExecuteWorkflow'; | ||
import * as Helpers from '@test/nodes/Helpers'; | ||
|
||
describe('GraphQL Node', () => { | ||
const mockResponse = { | ||
data: { | ||
nodes: {}, | ||
}, | ||
}; | ||
|
||
const tests: WorkflowTestData[] = [ | ||
{ | ||
description: 'should run Request Format JSON', | ||
input: { | ||
workflowData: Helpers.readJsonFileSync('nodes/GraphQL/test/workflow.json'), | ||
}, | ||
output: { | ||
nodeExecutionOrder: ['Start'], | ||
nodeData: { | ||
'Fetch Request Format JSON': [ | ||
[ | ||
{ | ||
json: mockResponse, | ||
}, | ||
], | ||
], | ||
}, | ||
}, | ||
nock: { | ||
baseUrl: 'https://api.n8n.io', | ||
mocks: [ | ||
{ | ||
method: 'post', | ||
path: '/graphql', | ||
statusCode: 200, | ||
responseBody: mockResponse, | ||
}, | ||
], | ||
}, | ||
}, | ||
]; | ||
|
||
const nodeTypes = Helpers.setup(tests); | ||
|
||
test.each(tests)('$description', async (testData) => { | ||
const { result } = await executeWorkflow(testData, nodeTypes); | ||
const resultNodeData = Helpers.getResultNodeData(result, testData); | ||
resultNodeData.forEach(({ nodeName, resultData }) => | ||
expect(resultData).toEqual(testData.output.nodeData[nodeName]), | ||
); | ||
expect(result.finished).toEqual(true); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
"meta": { | ||
"templateCredsSetupCompleted": true, | ||
"instanceId": "104a4d08d8897b8bdeb38aaca515021075e0bd8544c983c2bb8c86e6a8e6081c" | ||
}, | ||
"nodes": [ | ||
{ | ||
"parameters": {}, | ||
"id": "fb826323-2e48-4f11-bb0e-e12de32e22ee", | ||
"name": "When clicking \"Test workflow\"", | ||
"type": "n8n-nodes-base.manualTrigger", | ||
"typeVersion": 1, | ||
"position": [180, 160] | ||
}, | ||
{ | ||
"parameters": { | ||
"endpoint": "https://api.n8n.io/graphql", | ||
"requestFormat": "json", | ||
"query": "query {\n nodes(pagination: { limit: 1 }) {\n data {\n id\n attributes {\n name\n displayName\n description\n group\n codex\n createdAt\n }\n }\n }\n}" | ||
}, | ||
"name": "Fetch Request Format JSON", | ||
"type": "n8n-nodes-base.graphql", | ||
"typeVersion": 1, | ||
"position": [420, 160], | ||
"id": "7f8ceaf4-b82f-48d5-be0b-9fe3bfb35ee4" | ||
} | ||
], | ||
"connections": { | ||
"When clicking \"Test workflow\"": { | ||
"main": [ | ||
[ | ||
{ | ||
"node": "Fetch Request Format JSON", | ||
"type": "main", | ||
"index": 0 | ||
} | ||
] | ||
] | ||
} | ||
}, | ||
"pinData": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters