Convert Buffer.byteLength to string before assigning to Content-Length. (#956)

This change seems necessary in order to meet the new type definitions for
`res.setHeader` which mandate that the argument be a string, or an array of
strings.  Those type definitions were introduced via the `@types/node@9`
series of typing updates provided in [0], [1], [2].

With any luck, this will fix the failures being exhibited in CircleCI
tests[3] after we landed those typing updates.

[0]: https://github.com/apollographql/apollo-server/pull/907
[1]: https://github.com/apollographql/apollo-server/pull/927
[2]: https://github.com/apollographql/apollo-server/pull/939
[3]: https://circleci.com/gh/apollographql/apollo-server/1587
This commit is contained in:
Jesse Rosenberger 2018-04-11 11:17:55 +03:00 committed by GitHub
parent a8c2af0aa1
commit c2bba6b867
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -44,7 +44,10 @@ export function graphqlExpress(
}).then(
gqlResponse => {
res.setHeader('Content-Type', 'application/json');
res.setHeader('Content-Length', Buffer.byteLength(gqlResponse, 'utf8'));
res.setHeader(
'Content-Length',
Buffer.byteLength(gqlResponse, 'utf8').toString(),
);
res.write(gqlResponse);
res.end();
},