diff --git a/src/__tests__/http-test.js b/src/__tests__/http-test.js index 8958f6b9..c9e29d0b 100644 --- a/src/__tests__/http-test.js +++ b/src/__tests__/http-test.js @@ -791,7 +791,7 @@ function urlString(urlParams?: ?{ [param: string]: mixed, ... }) { const req = request(app) .post(urlString()) .set('Content-Type', 'application/graphql; charset=utf-16'); - req.write(new Buffer('{ test(who: "World") }', 'utf16le')); + req.write(Buffer.from('{ test(who: "World") }', 'utf16le')); const response = await req; expect(JSON.parse(response.text)).to.deep.equal({ @@ -940,7 +940,7 @@ function urlString(urlParams?: ?{ [param: string]: mixed, ... }) { const req = request(app) .post(urlString()) .set('Content-Type', 'application/graphql'); - req.write(new Buffer('{ test(who: "World") }')); + req.write(Buffer.from('{ test(who: "World") }')); const response = await req; expect(JSON.parse(response.text)).to.deep.equal({ @@ -957,7 +957,7 @@ function urlString(urlParams?: ?{ [param: string]: mixed, ... }) { post(app, urlString(), graphqlHTTP({ schema: TestSchema })); const req = request(app).post(urlString()); - req.write(new Buffer('{ test(who: "World") }')); + req.write(Buffer.from('{ test(who: "World") }')); const response = await req; expect(response.status).to.equal(400); @@ -975,7 +975,7 @@ function urlString(urlParams?: ?{ [param: string]: mixed, ... }) { const req = request(app) .post(urlString()) .set('Content-Type', 'application/graphql'); - req.write(new Buffer('{ test(who: "World") }')); + req.write(Buffer.from('{ test(who: "World") }')); const response = await req; expect(response.status).to.equal(400); diff --git a/src/index.js b/src/index.js index 7751e69e..9f082948 100644 --- a/src/index.js +++ b/src/index.js @@ -504,7 +504,7 @@ function canDisplayGraphiQL(request: $Request, params: GraphQLParams): boolean { * Helper function for sending a response using only the core Node server APIs. */ function sendResponse(response: $Response, type: string, data: string): void { - const chunk = new Buffer(data, 'utf8'); + const chunk = Buffer.from(data, 'utf8'); response.setHeader('Content-Type', type + '; charset=utf-8'); response.setHeader('Content-Length', String(chunk.length)); response.end(chunk);