From 4c4a7ef8a59ecaa6d68a89b38794fb9dd05327ae Mon Sep 17 00:00:00 2001 From: Ivan Goncharov Date: Wed, 10 Jul 2019 18:13:23 +0300 Subject: [PATCH] Simplify lambda functions (#541) --- src/__tests__/http-test.js | 68 ++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 39 deletions(-) diff --git a/src/__tests__/http-test.js b/src/__tests__/http-test.js index c9e29d0b..4ab6248e 100644 --- a/src/__tests__/http-test.js +++ b/src/__tests__/http-test.js @@ -903,12 +903,10 @@ function urlString(urlParams?: ?{ [param: string]: mixed, ... }) { post( app, urlString(), - graphqlHTTP(req => { - return { - schema: TestMutationSchema, - rootValue: { request: req }, - }; - }), + graphqlHTTP(req => ({ + schema: TestMutationSchema, + rootValue: { request: req }, + })), ); const response = await request(app) @@ -1060,13 +1058,11 @@ function urlString(urlParams?: ?{ [param: string]: mixed, ... }) { get( app, urlString(), - graphqlHTTP(req => { - return { - schema: TestSchema, - pretty: - ((url.parse(req.url, true) || {}).query || {}).pretty === '1', - }; - }), + graphqlHTTP(req => ({ + schema: TestSchema, + pretty: + ((url.parse(req.url, true) || {}).query || {}).pretty === '1', + })), ); const defaultResponse = await request(app).get( @@ -2086,15 +2082,13 @@ function urlString(urlParams?: ?{ [param: string]: mixed, ... }) { get( app, urlString(), - graphqlHTTP(() => { - return { - schema: TestSchema, - customParseFn(args) { - seenParseArgs = args; - return parse(new Source('{test}', 'Custom parse function')); - }, - }; - }), + graphqlHTTP(() => ({ + schema: TestSchema, + customParseFn(args) { + seenParseArgs = args; + return parse(new Source('{test}', 'Custom parse function')); + }, + })), ); const response = await request(app).get(urlString({ query: '----' })); @@ -2108,14 +2102,12 @@ function urlString(urlParams?: ?{ [param: string]: mixed, ... }) { get( app, urlString(), - graphqlHTTP(() => { - return { - schema: TestSchema, - customParseFn() { - throw new GraphQLError('my custom parse error'); - }, - }; - }), + graphqlHTTP(() => ({ + schema: TestSchema, + customParseFn() { + throw new GraphQLError('my custom parse error'); + }, + })), ); const response = await request(app).get(urlString({ query: '----' })); @@ -2134,15 +2126,13 @@ function urlString(urlParams?: ?{ [param: string]: mixed, ... }) { get( app, urlString(), - graphqlHTTP(() => { - return { - schema: TestSchema, - context: { foo: 'bar' }, - extensions({ context }) { - return { contextValue: JSON.stringify(context) }; - }, - }; - }), + graphqlHTTP(() => ({ + schema: TestSchema, + context: { foo: 'bar' }, + extensions({ context }) { + return { contextValue: JSON.stringify(context) }; + }, + })), ); const response = await request(app)