diff --git a/.eslintrc b/.eslintrc index 20736d34830..46a5a102e43 100644 --- a/.eslintrc +++ b/.eslintrc @@ -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", diff --git a/docs/source/development-testing/reducing-bundle-size.mdx b/docs/source/development-testing/reducing-bundle-size.mdx index c6438bae29c..58ad4571428 100644 --- a/docs/source/development-testing/reducing-bundle-size.mdx +++ b/docs/source/development-testing/reducing-bundle-size.mdx @@ -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. @@ -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), }, }); ``` @@ -43,7 +44,7 @@ const nextConfig = { webpack(config, { webpack }) { config.plugins.push( new webpack.DefinePlugin({ - 'globalThis.__DEV__': false, + "globalThis.__DEV__": false, }) ); return config; @@ -62,12 +63,12 @@ With `create-react-app`, you need to use a third-party package like [`craco`](ht ```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, }), ], }, @@ -97,7 +98,7 @@ module.exports = { ```js config.plugins.push( new webpack.DefinePlugin({ - 'globalThis.__DEV__': false, + "globalThis.__DEV__": false, }) ); ``` @@ -120,7 +121,7 @@ export default [ compress: { toplevel: true, global_defs: { - '@globalThis.__DEV__': 'false', + "@globalThis.__DEV__": "false", }, }, }), @@ -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.
diff --git a/src/core/QueryManager.ts b/src/core/QueryManager.ts index 37eb4102bad..a2493076e6a 100644 --- a/src/core/QueryManager.ts +++ b/src/core/QueryManager.ts @@ -957,7 +957,7 @@ export class QueryManager { public startGraphQLSubscription({ query, fetchPolicy, - errorPolicy = 'none', + errorPolicy = "none", variables, context = {}, }: SubscriptionOptions): Observable> { @@ -995,13 +995,13 @@ export class QueryManager { // `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; @@ -1567,8 +1567,8 @@ export class QueryManager { 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;