From 11cfa9d8a3346651d5ff42241bec7aad844fee49 Mon Sep 17 00:00:00 2001 From: tian-sheng-low Date: Thu, 22 Jun 2023 19:04:07 +0900 Subject: [PATCH] add a failing test to #5173 https://github.com/ardatan/graphql-tools/issues/5173 --- .../http/tests/buildHTTPExecutor.test.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/packages/executors/http/tests/buildHTTPExecutor.test.ts b/packages/executors/http/tests/buildHTTPExecutor.test.ts index 8cce4fa68e8..555d359bcb7 100644 --- a/packages/executors/http/tests/buildHTTPExecutor.test.ts +++ b/packages/executors/http/tests/buildHTTPExecutor.test.ts @@ -42,4 +42,23 @@ describe('buildHTTPExecutor', () => { ], }); }); + it('handle responses other than 2XX', async () => { + const executor = buildHTTPExecutor({ + fetch: (_url, init) => new Response(JSON.stringify({ data: init }), { status: 500 }), + }); + const result = await executor({ + document: parse(/* GraphQL */ ` + query { + hello + } + `), + }); + expect(result).toMatchObject({ + errors: [ + { + message: 'Internal Server Error', + }, + ], + }); + }); });