Skip to content

Commit 3d30941

Browse files
SaerisSaraVieira
authored andcommitted
Refactor GraphQL Result Param Reassignment (codesandbox#1890)
Instead of reassigning values on the result object, which previously required disabling eslint, this refactor uses ES6 object destructuring and rest/spread to create a new result object.
1 parent 7ab5bb8 commit 3d30941

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

packages/app/src/app/graphql/client.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,11 @@ const authLink = setContext((_, { headers }) => {
2424
});
2525

2626
const absintheAfterware = new ApolloLink((operation, forward) =>
27-
forward(operation).map(result => {
28-
/* eslint-disable no-param-reassign */
29-
result.errors = result.payload.errors;
30-
result.data = result.payload.data;
31-
/* eslint-enable */
32-
33-
return result;
34-
})
27+
forward(operation).map(({ payload, ...result }) => ({
28+
...result,
29+
errors: payload.errors,
30+
data: payload.data
31+
}))
3532
);
3633

3734
const errorHandler = onError(({ graphQLErrors, networkError }) => {

0 commit comments

Comments
 (0)