-
-
Notifications
You must be signed in to change notification settings - Fork 458
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make further bundle size optimisations (#375)
* Extract result/error generation from exchanges * Replace process.env.NODE_ENV in minified bundle This will give us accurate build numbers * Remove unnecessary rest spread from components This removes the __rest polyfill from our bundles. The rest spread isn't necessary since the props are compatible interfaces that extend the hooks' args. * Replace debug exchange with noop in production * Add missing result export in utils * (refactor) - avoid implicit returns where we have no value in returns like in forEach statements * (refactor) - avoid destructuring when the variable is only used once * (refactor) - convert the two step return of error.ts in a one step return
- Loading branch information
1 parent
e781a28
commit f30b28f
Showing
13 changed files
with
118 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { Operation, OperationResult } from '../types'; | ||
import { CombinedError } from './error'; | ||
|
||
export const makeResult = ( | ||
operation: Operation, | ||
result: any, | ||
response?: any | ||
): OperationResult => ({ | ||
operation, | ||
data: result.data, | ||
error: Array.isArray(result.errors) | ||
? new CombinedError({ | ||
graphQLErrors: result.errors, | ||
response, | ||
}) | ||
: undefined, | ||
extensions: | ||
typeof result.extensions === 'object' && result.extensions !== null | ||
? result.extensions | ||
: undefined, | ||
}); | ||
|
||
export const makeErrorResult = ( | ||
operation: Operation, | ||
error: Error, | ||
response?: any | ||
): OperationResult => ({ | ||
operation, | ||
data: undefined, | ||
error: new CombinedError({ | ||
networkError: error, | ||
response, | ||
}), | ||
extensions: undefined, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters