Skip to content
This repository has been archived by the owner on Mar 20, 2023. It is now read-only.

Commit

Permalink
Simplify lambda functions (#541)
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov committed Jul 10, 2019
1 parent 0473097 commit 360bebf
Showing 1 changed file with 29 additions and 39 deletions.
68 changes: 29 additions & 39 deletions src/__tests__/http-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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: '----' }));
Expand All @@ -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: '----' }));
Expand All @@ -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)
Expand Down

0 comments on commit 360bebf

Please sign in to comment.