From 78825c6893df3f707c77d6863f7d8177520e27e6 Mon Sep 17 00:00:00 2001 From: Jens Ulrich Hjuler Pedersen Date: Thu, 25 Apr 2019 10:05:26 +0200 Subject: [PATCH] Fix Headers bug in IE11 When calling `new Headers(undefined)` in IE11 an `Invalid argument` exception is thrown. With this in place, we'll call it with an empty object, resulting in an empty Headers object. --- CHANGELOG.md | 1 + packages/apollo-datasource-rest/src/RESTDataSource.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 35420adf7af..c0b03eba441 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ### vNEXT - Allow `GraphQLRequestListener` callbacks in plugins to depend on `this`. [PR #2470](https://github.com/apollographql/apollo-server/pull/2470) +- Fix `Invalid argument` in IE11, when using `apollo-datasource-rest` when `this.headers` is `undefined`. [PR #2607](https://github.com/apollographql/apollo-server/pull/2607) ### v2.4.8 diff --git a/packages/apollo-datasource-rest/src/RESTDataSource.ts b/packages/apollo-datasource-rest/src/RESTDataSource.ts index fc12f508884..667038e114a 100644 --- a/packages/apollo-datasource-rest/src/RESTDataSource.ts +++ b/packages/apollo-datasource-rest/src/RESTDataSource.ts @@ -201,7 +201,7 @@ export abstract class RESTDataSource extends DataSource { } if (!(init.headers && init.headers instanceof Headers)) { - init.headers = new Headers(init.headers); + init.headers = new Headers(init.headers || {}); } const options = init as RequestOptions;