Skip to content

Commit

Permalink
Reformat missed files from #11170
Browse files Browse the repository at this point in the history
  • Loading branch information
jerelmiller committed Aug 30, 2023
1 parent f0bb56c commit 994ae91
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 19 deletions.
5 changes: 1 addition & 4 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,7 @@
"message": "Please only use the namespace import syntax (`import * as React from 'react'`) for React imports!"
}
],
"import/consistent-type-specifier-style": [
"error",
"prefer-top-level"
],
"import/consistent-type-specifier-style": ["error", "prefer-top-level"],
"import/extensions": [
"error",
"always",
Expand Down
19 changes: 10 additions & 9 deletions docs/source/development-testing/reducing-bundle-size.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ description: Squeeze those last few bytes out of your production build

Two quick configuration changes can help your reduce your bundle size: turning off Apollo Client's development mode and picking a consistent style for your imports.
Every byte counts in optimizing your app's performance.

## Turning off development mode

By default, Apollo Client is in "development mode". That means Apollo Client performs additional checks and the browser console displays warnings.
Expand All @@ -25,7 +26,7 @@ Here are some bundler-specific suggestions for configuring your bundler to remov
export default defineConfig({
// ...
define: {
'globalThis.__DEV__': JSON.stringify(false),
"globalThis.__DEV__": JSON.stringify(false),
},
});
```
Expand All @@ -43,7 +44,7 @@ const nextConfig = {
webpack(config, { webpack }) {
config.plugins.push(
new webpack.DefinePlugin({
'globalThis.__DEV__': false,
"globalThis.__DEV__": false,
})
);
return config;
Expand All @@ -62,12 +63,12 @@ With `create-react-app`, you need to use a third-party package like [`craco`](ht
<ExpansionPanel title="Click to expand suggested configuration">

```js title="craco.config.js"
const webpack = require('webpack');
const webpack = require("webpack");
module.exports = {
webpack: {
plugins: [
new webpack.DefinePlugin({
'globalThis.__DEV__': false,
"globalThis.__DEV__": false,
}),
],
},
Expand Down Expand Up @@ -97,7 +98,7 @@ module.exports = {
```js
config.plugins.push(
new webpack.DefinePlugin({
'globalThis.__DEV__': false,
"globalThis.__DEV__": false,
})
);
```
Expand All @@ -120,7 +121,7 @@ export default [
compress: {
toplevel: true,
global_defs: {
'@globalThis.__DEV__': 'false',
"@globalThis.__DEV__": "false",
},
},
}),
Expand Down Expand Up @@ -171,11 +172,11 @@ Apollo Client offers these two styles of imports:

```js
// "main entrypoint import" style
import { ApolloClient, InMemoryCache, useQuery } from '@apollo/client';
import { ApolloClient, InMemoryCache, useQuery } from "@apollo/client";

// "deep entrypoint import" style
import { ApolloClient, InMemoryCache } from '@apollo/client/core';
import { useQuery } from '@apollo/client/react/hooks';
import { ApolloClient, InMemoryCache } from "@apollo/client/core";
import { useQuery } from "@apollo/client/react/hooks";
```

With many modern bundlers, it should not matter which of these styles you choose.<br />
Expand Down
12 changes: 6 additions & 6 deletions src/core/QueryManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,7 @@ export class QueryManager<TStore> {
public startGraphQLSubscription<T = any>({
query,
fetchPolicy,
errorPolicy = 'none',
errorPolicy = "none",
variables,
context = {},
}: SubscriptionOptions): Observable<FetchResult<T>> {
Expand Down Expand Up @@ -995,13 +995,13 @@ export class QueryManager<TStore> {
// `errorPolicy` is a mechanism for handling GraphQL errors, according
// to our documentation, so we throw protocol errors regardless of the
// set error policy.
if (errorPolicy === 'none' || hasProtocolErrors) {
if (errorPolicy === "none" || hasProtocolErrors) {
throw new ApolloError(errors);
}
}

if (errorPolicy === 'ignore') {
delete result.errors
if (errorPolicy === "ignore") {
delete result.errors;
}

return result;
Expand Down Expand Up @@ -1567,8 +1567,8 @@ export class QueryManager<TStore> {
fetchPolicy === "no-cache"
? CacheWriteBehavior.FORBID
: // Watched queries must opt into overwriting existing data on refetch,
// by passing refetchWritePolicy: "overwrite" in their WatchQueryOptions.
networkStatus === NetworkStatus.refetch &&
// by passing refetchWritePolicy: "overwrite" in their WatchQueryOptions.
networkStatus === NetworkStatus.refetch &&
refetchWritePolicy !== "merge"
? CacheWriteBehavior.OVERWRITE
: CacheWriteBehavior.MERGE;
Expand Down

0 comments on commit 994ae91

Please sign in to comment.