Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a new pull request by comparing changes across two branches. #430

Merged
merged 125 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
125 commits
Select commit Hold shift + click to select a range
5e8b5e0
Avoid destructively modifying result.data in QueryInfo#markResult.
benjamn Feb 24, 2023
7f9c5ac
Test adjustments after fixing QueryInfo#markResult.
benjamn Aug 29, 2023
a201111
New test of re-reading incomplete network results from cache.
benjamn Aug 29, 2023
7c2bc08
Run 'npx changeset' for PR #11202.
benjamn Sep 8, 2023
a031860
Run 'npm run format' for code modified in PR #11202.
benjamn Sep 13, 2023
d8c6072
Bump size-limit +8 bytes.
benjamn Sep 13, 2023
2ad8485
extend test to distinguish between cache & network
phryneas Sep 14, 2023
ec5d86c
defensive copy of `result` at the top of `markResult`
phryneas Sep 14, 2023
8b6e10b
Merge pull request #11202 from apollographql/issue-9293-fix-QueryInfo…
benjamn Sep 14, 2023
9ee47f8
Add `.changeset/` directory to `.prettierignore`.
benjamn Sep 15, 2023
57b4915
Merge branch 'main' into release-3.9.
benjamn Sep 15, 2023
c1b8c91
chore: enter prerelease mode
alessbell Sep 19, 2023
8d2b4e1
Ability to dynamically match mocks (#6701)
prowe Sep 19, 2023
a0fbcd8
Version Packages (alpha) (#11210)
github-actions[bot] Sep 19, 2023
698f821
Merge branch 'main' into release-3.9
alessbell Sep 19, 2023
1a072b0
Merge branch 'main' of github.com:apollographql/apollo-client into re…
alessbell Sep 19, 2023
4cdcb91
Version Packages
alessbell Sep 19, 2023
217c59e
remove peerDependency on graphql 14 (#11231)
phryneas Sep 20, 2023
a4c38d6
Merge branch 'main' into release-3.9
alessbell Sep 21, 2023
4d64a6f
Feature request 241: reuse mocks in MockLink / MockedProvider (#11178)
sebakerckhof Sep 21, 2023
33e0d78
Version Packages (alpha) (#11239)
github-actions[bot] Sep 21, 2023
d08970d
Decouple `canonicalStringify` from `ObjectCanon` (#11254)
benjamn Oct 5, 2023
632940e
Merge tag v3.8.5 into release-3.9
phryneas Oct 11, 2023
ba5faa5
Version Packages (alpha) (#11273)
github-actions[bot] Oct 11, 2023
1bec61a
Merge remote-tracking branch 'origin/main' into release-3.9
jerelmiller Oct 17, 2023
701a6fb
Bump size-limit
jerelmiller Oct 17, 2023
39105c1
Merge remote-tracking branch 'origin/main' into release-3.9
phryneas Nov 2, 2023
3862f9b
Add a defaultContext property on ApolloClient (#11275)
phryneas Nov 2, 2023
46ab032
feat: add multipart subscription network adapters for Relay and urql …
alessbell Nov 2, 2023
be2029b
Version Packages (alpha) (#11336)
github-actions[bot] Nov 2, 2023
776631d
Add `reset` method to `print`, hook up to `InMemoryCache.gc` (#11343)
phryneas Nov 7, 2023
d6d1491
use external package to wrap `React` imports to circumvent non-existi…
phryneas Nov 8, 2023
950cae8
Version Packages (alpha) (#11347)
github-actions[bot] Nov 8, 2023
bd26676
Add `reset` method to `DocumentTransform`, hook `InMemoryCache.addTyp…
phryneas Nov 9, 2023
981a06f
Merge remote-tracking branch 'origin/main' into release-3.9
phryneas Nov 14, 2023
b0bf0d8
fix up type in 3.9 branch after merge (#11362)
phryneas Nov 14, 2023
7d8e184
`InMemoryCache.gc`: also trigger `FragmentRegistry.resetCaches` (#11355)
phryneas Nov 14, 2023
e6090f3
Merge remote-tracking branch 'origin/main' into release-3.9
phryneas Nov 17, 2023
ac4e382
update size-limit
phryneas Nov 17, 2023
ebd8fe2
Clarify types of `EntityStore.makeCacheKey` (#11371)
phryneas Nov 20, 2023
0b3c308
Merge branch 'main' into release-3.9
jerelmiller Nov 21, 2023
d9ca4f0
Ensure `defaultContext` is also used for mutations and subscriptions …
phryneas Nov 28, 2023
a815873
Add a new `useLoadableQuery` hook (#11300)
jerelmiller Nov 28, 2023
cc4ac7e
Address potential memory leaks in `FragmentRegistry` (#11356)
phryneas Nov 29, 2023
30d17bf
`print`: use `WeakCache` instead of `WeakMap` (#11367)
phryneas Nov 29, 2023
25e2cb4
`parse` function: improve memory management (#11370)
phryneas Nov 29, 2023
4dce867
`QueryManager.transformCache`: use `WeakCache` (#11387)
phryneas Nov 29, 2023
7d939f8
fix potential memory leak in `Concast`, add tests (#11358)
phryneas Nov 30, 2023
1759066
`QueryManager.inFlightLinkObservables`: use a strong `Trie` (#11345)
phryneas Dec 1, 2023
aaf8c79
`useSuspenseQuery`: remove `promiseCache` (#11363)
phryneas Dec 1, 2023
44b27a6
Merge remote-tracking branch 'origin/main' into release-3.9
phryneas Dec 1, 2023
ea8fd38
apply prettier
phryneas Dec 1, 2023
b1ff9c2
update api-reports
phryneas Dec 1, 2023
139acd1
`documentTransform`: use `optimism` and `WeakCache` (#11389)
phryneas Dec 1, 2023
db5f5fd
`useBackgroundQuery`: remove `promiseCache`, work around race conditi…
phryneas Dec 1, 2023
ac58ca0
Update `useLoadableQuery` to remove `promiseCache` (#11402)
jerelmiller Dec 4, 2023
6970343
Merge branch 'main' into release-3.9
jerelmiller Dec 5, 2023
838095b
Version Packages (alpha) (#11353)
github-actions[bot] Dec 5, 2023
c82c7fd
Merge branch 'main' into release-3.9
jerelmiller Dec 6, 2023
3f7eecb
Add `skipPollAttempt` option to control polling refetch behavior (#11…
aditya-kumawat Dec 6, 2023
d05297d
Fix changeset formatting
jerelmiller Dec 6, 2023
221dd99
Allow usage of WeakMap in React Native Hermes (#10804)
phryneas Dec 8, 2023
2a47164
Persisted Query Link: improve memory management (#11369)
phryneas Dec 14, 2023
f5420b0
add central configuration for Apollo Client cache sizes (#11408)
phryneas Dec 15, 2023
fea0023
Copy and use ApiDoc components from docs repo (#11416)
phryneas Dec 7, 2023
efeea04
Update netlify.toml
phryneas Dec 8, 2023
865659b
Update react-native.md - Adds react native devtool supported by flipp…
mohit23x Dec 8, 2023
98431c1
chore(deps): update actions/stale action to v9 (#11423)
renovate[bot] Dec 11, 2023
13c27bb
chore(deps): update cimg/node docker tag to v21.4.0 (#11422)
renovate[bot] Dec 11, 2023
aafcd3e
chore(deps): update all devdependencies (#11406)
renovate[bot] Dec 12, 2023
dabb1f8
chore(deps): update all dependencies - patch updates (#11421)
renovate[bot] Dec 12, 2023
ae7c765
Merge branch 'main' into release-3.9
phryneas Dec 15, 2023
2e7203b
experimental `ApolloClient.getMemoryInternals` helper (#11409)
phryneas Dec 15, 2023
07fcf6a
feat: Allow returning `IGNORE` sentinel from `optimisticResponse` fun…
sf-twingate Dec 15, 2023
58db5c3
Add the ability to preload a query outside of React (#11412)
jerelmiller Dec 18, 2023
5cce53e
deprecate `canonizeResults` (#11435)
phryneas Dec 18, 2023
b07d9d8
Fix doc warning in useQueryRefHandlers
jerelmiller Dec 18, 2023
b05a5a9
Regenerate api report
jerelmiller Dec 18, 2023
283b4f6
Merge branch 'main' into release-3.9
jerelmiller Dec 18, 2023
e9b5130
Switch to use the beta tag
jerelmiller Dec 18, 2023
2ba07ac
Reset package.json version to ensure changesets records the right ver…
jerelmiller Dec 18, 2023
3a2240f
Version Packages (beta) (#11417)
github-actions[bot] Dec 18, 2023
33454f0
Add `react/internal` entry point and update existing imports (#11439)
jerelmiller Dec 19, 2023
3cbb207
Rewrite `useBackgroundQuery` tests to use Profiler (#11437)
jerelmiller Dec 19, 2023
6d46ab9
Remove `retain` call from `useBackgroundQuery` to allow for auto disp…
jerelmiller Dec 19, 2023
62f3b6d
Simplify RetryLink, fix potential memory leak (#11424)
phryneas Dec 20, 2023
14edebe
ObservableQuery: only report results for the current variables (#11078)
phryneas Dec 20, 2023
ff5a332
add deprecation warnings for HOC and Render Prop docblocks (#11443)
phryneas Dec 20, 2023
de5b878
Add a "memory management" documentation page (#11415)
phryneas Dec 20, 2023
4b6f2bc
Remove `retain` from `useLoadableQuery` to allow for auto disposal (#…
jerelmiller Dec 21, 2023
fe56f68
Version Packages (beta) (#11440)
github-actions[bot] Dec 21, 2023
d758118
chore: add docs for relay and urql network adapters (#11460)
alessbell Jan 3, 2024
a604ac3
chore: add docs for skipping an optimistic update via optimisticRespo…
alessbell Jan 3, 2024
0ee2a57
Merge branch 'main' into release-3.9
alessbell Jan 12, 2024
416db65
chore: bump size limits, fix new lint error since merging main
alessbell Jan 12, 2024
48f73dc
Prepare for rc release
jerelmiller Jan 17, 2024
8e79ad4
Merge remote-tracking branch 'origin/main' into release-3.9
jerelmiller Jan 17, 2024
1190aa5
Increase default memory limits (#11495)
jerelmiller Jan 17, 2024
d0afb45
Switch changeset to minor version bump
jerelmiller Jan 17, 2024
9f5f801
Version Packages (rc) (#11496)
github-actions[bot] Jan 17, 2024
fb0a255
Merge remote-tracking branch 'origin/main' into release-3.9
jerelmiller Jan 18, 2024
67f62e3
Add changeset to bump rc version (#11503)
jerelmiller Jan 18, 2024
cfe6b78
Version Packages (rc) (#11504)
github-actions[bot] Jan 18, 2024
4464050
Add doc comment for `headers` property on ApolloClient (#11508)
jerelmiller Jan 22, 2024
25b83da
chore: update api-reports
phryneas Jan 22, 2024
2a67ffc
move hook documentation (and others) into code, improve documentation…
phryneas Jan 24, 2024
2964a13
Document new React APIs in code - Part 2 of 2 (#11523)
jerelmiller Jan 26, 2024
deffc69
Add docs component for API members that are marked as alpha/beta (#11…
jerelmiller Jan 26, 2024
3252bb7
chore: add client-typescript team to CODEOWNERS (#11534)
alessbell Jan 29, 2024
86bf814
chore(deps): update slackapi/slack-github-action action to v1.25.0 (#…
renovate[bot] Jan 29, 2024
16ab77c
chore(deps): update cimg/node docker tag to v21.6.1 (#11509)
renovate[bot] Jan 29, 2024
cca227e
chore(deps): update dependency @testing-library/jest-dom to v6.3.0 (#…
renovate[bot] Jan 29, 2024
cd55497
chore(deps): update peter-evans/create-or-update-comment action to v4…
renovate[bot] Jan 29, 2024
fca8c7b
chore(deps): update all dependencies - patch updates (#11530)
renovate[bot] Jan 29, 2024
cd2a07c
chore(deps): update andstor/file-existence-action action to v3 (#11535)
renovate[bot] Jan 29, 2024
3c11973
Update ROADMAP.md
alessbell Jan 29, 2024
68166a2
chore: use Node.js v20 in GitHub Actions workflows (#11536)
alessbell Jan 29, 2024
2ebb0c5
Update getting started doc to use vite (#11352)
gento-ogane Jan 29, 2024
cae1475
Merge remote-tracking branch 'origin/main' into release-3.9
jerelmiller Jan 30, 2024
2c836af
Exit prerelease
alessbell Jan 30, 2024
91dadd5
Merge pull request #11220 from apollographql/release-3.9
alessbell Jan 30, 2024
40685cf
chore: only attempt to create a version packages PR if still in prere…
alessbell Jan 30, 2024
9f2ccdb
v3.9.0 (#11540)
github-actions[bot] Jan 30, 2024
bf3a4c6
3.9 Documentation (#11537)
jerelmiller Jan 30, 2024
85fb665
Switch back to main branch for doc deploys (#11542)
jerelmiller Jan 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add a "memory management" documentation page (apollographql#11415)
Co-authored-by: Maria Elisabeth Schreiber <[email protected]>
Co-authored-by: Jerel Miller <[email protected]>
Co-authored-by: jerelmiller <[email protected]>
  • Loading branch information
4 people authored Dec 20, 2023
commit de5b878ebfbfee956f3396e1f4e38a42fa3df017
2 changes: 0 additions & 2 deletions .api-reports/api-report-core.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ export class ApolloClient<TCacheShape> implements DataProxy {
get documentTransform(): DocumentTransform;
extract(optimistic?: boolean): TCacheShape;
// Warning: (ae-forgotten-export) The symbol "getApolloClientMemoryInternals" needs to be exported by the entry point index.d.ts
//
// @internal
getMemoryInternals?: typeof getApolloClientMemoryInternals;
getObservableQueries(include?: RefetchQueriesInclude): Map<string, ObservableQuery<any>>;
getResolvers(): Resolvers;
Expand Down
2 changes: 0 additions & 2 deletions .api-reports/api-report-react.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,6 @@ class ApolloClient<TCacheShape> implements DataProxy {
get documentTransform(): DocumentTransform;
extract(optimistic?: boolean): TCacheShape;
// Warning: (ae-forgotten-export) The symbol "getApolloClientMemoryInternals" needs to be exported by the entry point index.d.ts
//
// @internal
getMemoryInternals?: typeof getApolloClientMemoryInternals;
// Warning: (ae-forgotten-export) The symbol "RefetchQueriesInclude" needs to be exported by the entry point index.d.ts
getObservableQueries(include?: RefetchQueriesInclude): Map<string, ObservableQuery<any>>;
Expand Down
2 changes: 0 additions & 2 deletions .api-reports/api-report-react_components.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,6 @@ class ApolloClient<TCacheShape> implements DataProxy {
get documentTransform(): DocumentTransform;
extract(optimistic?: boolean): TCacheShape;
// Warning: (ae-forgotten-export) The symbol "getApolloClientMemoryInternals" needs to be exported by the entry point index.d.ts
//
// @internal
getMemoryInternals?: typeof getApolloClientMemoryInternals;
// Warning: (ae-forgotten-export) The symbol "RefetchQueriesInclude" needs to be exported by the entry point index.d.ts
getObservableQueries(include?: RefetchQueriesInclude): Map<string, ObservableQuery<any>>;
Expand Down
2 changes: 0 additions & 2 deletions .api-reports/api-report-react_context.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,6 @@ class ApolloClient<TCacheShape> implements DataProxy {
get documentTransform(): DocumentTransform;
extract(optimistic?: boolean): TCacheShape;
// Warning: (ae-forgotten-export) The symbol "getApolloClientMemoryInternals" needs to be exported by the entry point index.d.ts
//
// @internal
getMemoryInternals?: typeof getApolloClientMemoryInternals;
// Warning: (ae-forgotten-export) The symbol "RefetchQueriesInclude" needs to be exported by the entry point index.d.ts
getObservableQueries(include?: RefetchQueriesInclude): Map<string, ObservableQuery<any>>;
Expand Down
2 changes: 0 additions & 2 deletions .api-reports/api-report-react_hoc.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,6 @@ class ApolloClient<TCacheShape> implements DataProxy {
get documentTransform(): DocumentTransform;
extract(optimistic?: boolean): TCacheShape;
// Warning: (ae-forgotten-export) The symbol "getApolloClientMemoryInternals" needs to be exported by the entry point index.d.ts
//
// @internal
getMemoryInternals?: typeof getApolloClientMemoryInternals;
// Warning: (ae-forgotten-export) The symbol "RefetchQueriesInclude" needs to be exported by the entry point index.d.ts
getObservableQueries(include?: RefetchQueriesInclude): Map<string, ObservableQuery<any>>;
Expand Down
2 changes: 0 additions & 2 deletions .api-reports/api-report-react_hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@ class ApolloClient<TCacheShape> implements DataProxy {
get documentTransform(): DocumentTransform;
extract(optimistic?: boolean): TCacheShape;
// Warning: (ae-forgotten-export) The symbol "getApolloClientMemoryInternals" needs to be exported by the entry point index.d.ts
//
// @internal
getMemoryInternals?: typeof getApolloClientMemoryInternals;
// Warning: (ae-forgotten-export) The symbol "RefetchQueriesInclude" needs to be exported by the entry point index.d.ts
getObservableQueries(include?: RefetchQueriesInclude): Map<string, ObservableQuery<any>>;
Expand Down
2 changes: 0 additions & 2 deletions .api-reports/api-report-react_internal.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@ class ApolloClient<TCacheShape> implements DataProxy {
get documentTransform(): DocumentTransform;
extract(optimistic?: boolean): TCacheShape;
// Warning: (ae-forgotten-export) The symbol "getApolloClientMemoryInternals" needs to be exported by the entry point index.d.ts
//
// @internal
getMemoryInternals?: typeof getApolloClientMemoryInternals;
// Warning: (ae-forgotten-export) The symbol "RefetchQueriesInclude" needs to be exported by the entry point index.d.ts
getObservableQueries(include?: RefetchQueriesInclude): Map<string, ObservableQuery<any>>;
Expand Down
2 changes: 0 additions & 2 deletions .api-reports/api-report-react_ssr.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,6 @@ class ApolloClient<TCacheShape> implements DataProxy {
get documentTransform(): DocumentTransform;
extract(optimistic?: boolean): TCacheShape;
// Warning: (ae-forgotten-export) The symbol "getApolloClientMemoryInternals" needs to be exported by the entry point index.d.ts
//
// @internal
getMemoryInternals?: typeof getApolloClientMemoryInternals;
// Warning: (ae-forgotten-export) The symbol "RefetchQueriesInclude" needs to be exported by the entry point index.d.ts
getObservableQueries(include?: RefetchQueriesInclude): Map<string, ObservableQuery<any>>;
Expand Down
2 changes: 0 additions & 2 deletions .api-reports/api-report-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,6 @@ class ApolloClient<TCacheShape> implements DataProxy {
get documentTransform(): DocumentTransform;
extract(optimistic?: boolean): TCacheShape;
// Warning: (ae-forgotten-export) The symbol "getApolloClientMemoryInternals" needs to be exported by the entry point index.d.ts
//
// @internal
getMemoryInternals?: typeof getApolloClientMemoryInternals;
// Warning: (ae-forgotten-export) The symbol "RefetchQueriesInclude" needs to be exported by the entry point index.d.ts
getObservableQueries(include?: RefetchQueriesInclude): Map<string, ObservableQuery<any>>;
Expand Down
2 changes: 0 additions & 2 deletions .api-reports/api-report-testing_core.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@ class ApolloClient<TCacheShape> implements DataProxy {
get documentTransform(): DocumentTransform;
extract(optimistic?: boolean): TCacheShape;
// Warning: (ae-forgotten-export) The symbol "getApolloClientMemoryInternals" needs to be exported by the entry point index.d.ts
//
// @internal
getMemoryInternals?: typeof getApolloClientMemoryInternals;
// Warning: (ae-forgotten-export) The symbol "RefetchQueriesInclude" needs to be exported by the entry point index.d.ts
getObservableQueries(include?: RefetchQueriesInclude): Map<string, ObservableQuery<any>>;
Expand Down
2 changes: 0 additions & 2 deletions .api-reports/api-report-utilities.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,6 @@ class ApolloClient<TCacheShape> implements DataProxy {
get documentTransform(): DocumentTransform;
extract(optimistic?: boolean): TCacheShape;
// Warning: (ae-forgotten-export) The symbol "getApolloClientMemoryInternals" needs to be exported by the entry point index.d.ts
//
// @internal
getMemoryInternals?: typeof getApolloClientMemoryInternals;
// Warning: (ae-forgotten-export) The symbol "RefetchQueriesInclude" needs to be exported by the entry point index.d.ts
getObservableQueries(include?: RefetchQueriesInclude): Map<string, ObservableQuery<any>>;
Expand Down
2 changes: 0 additions & 2 deletions .api-reports/api-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,6 @@ export class ApolloClient<TCacheShape> implements DataProxy {
get documentTransform(): DocumentTransform;
extract(optimistic?: boolean): TCacheShape;
// Warning: (ae-forgotten-export) The symbol "getApolloClientMemoryInternals" needs to be exported by the entry point index.d.ts
//
// @internal
getMemoryInternals?: typeof getApolloClientMemoryInternals;
getObservableQueries(include?: RefetchQueriesInclude): Map<string, ObservableQuery<any>>;
getResolvers(): Resolvers;
Expand Down
106 changes: 69 additions & 37 deletions config/apiExtractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
IConfigFile,
} from "@microsoft/api-extractor";
import { parseArgs } from "node:util";
import fs from "node:fs";

// @ts-ignore
import { map } from "./entryPoints.js";
Expand Down Expand Up @@ -40,37 +41,67 @@ const packageJsonFullPath = path.resolve(__dirname, "../package.json");

process.exitCode = 0;

map((entryPoint: { dirs: string[] }) => {
if (entryPoint.dirs.length > 0 && parsed.values["main-only"]) return;
const tempDir = fs.mkdtempSync("api-model");
try {
if (parsed.values.generate?.includes("docModel")) {
console.log(
"\n\nCreating API extractor docmodel for the a combination of all entry points"
);
const dist = path.resolve(__dirname, "../dist");
const entryPoints = map((entryPoint: { dirs: string[] }) => {
return `export * from "${dist}/${entryPoint.dirs.join("/")}/index.d.ts";`;
}).join("\n");
const entryPointFile = path.join(tempDir, "entry.d.ts");
fs.writeFileSync(entryPointFile, entryPoints);

buildReport(entryPointFile, "docModel");
}

const path = entryPoint.dirs.join("/");
const mainEntryPointFilePath =
`<projectFolder>/dist/${path}/index.d.ts`.replace("//", "/");
console.log(
"\n\nCreating API extractor report for " + mainEntryPointFilePath
);
if (parsed.values.generate?.includes("apiReport")) {
map((entryPoint: { dirs: string[] }) => {
const path = entryPoint.dirs.join("/");
const mainEntryPointFilePath =
`<projectFolder>/dist/${path}/index.d.ts`.replace("//", "/");
console.log(
"\n\nCreating API extractor report for " + mainEntryPointFilePath
);
buildReport(
mainEntryPointFilePath,
"apiReport",
`api-report${path ? "-" + path.replace(/\//g, "_") : ""}.md`
);
});
}
} finally {
fs.rmSync(tempDir, { recursive: true });
}

function buildReport(
mainEntryPointFilePath: string,
mode: "apiReport" | "docModel",
reportFileName = ""
) {
const configObject: IConfigFile = {
...(JSON.parse(JSON.stringify(baseConfig)) as IConfigFile),
mainEntryPointFilePath,
};

configObject.apiReport!.reportFileName = `api-report${
path ? "-" + path.replace(/\//g, "_") : ""
}.md`;

configObject.apiReport!.enabled =
parsed.values.generate?.includes("apiReport") || false;

configObject.docModel!.enabled =
parsed.values.generate?.includes("docModel") || false;

if (entryPoint.dirs.length !== 0) {
if (mode === "apiReport") {
configObject.apiReport!.enabled = true;
configObject.docModel = { enabled: false };
configObject.tsdocMetadata = { enabled: false };
configObject.messages!.extractorMessageReporting![
"ae-unresolved-link"
]!.logLevel = ExtractorLogLevel.None;
configObject.apiReport!.reportFileName = reportFileName;
} else {
configObject.docModel!.enabled = true;
configObject.apiReport = {
enabled: false,
// this has to point to an existing folder, otherwise the extractor will fail
// but it will not write the file
reportFileName: "disabled.md",
reportFolder: tempDir,
};
}

const extractorConfig = ExtractorConfig.prepare({
Expand All @@ -85,22 +116,23 @@ map((entryPoint: { dirs: string[] }) => {
});

let succeededAdditionalChecks = true;
const contents = readFileSync(extractorConfig.reportFilePath, "utf8");

if (contents.includes("rehackt")) {
succeededAdditionalChecks = false;
console.error(
"❗ %s contains a reference to the `rehackt` package!",
extractorConfig.reportFilePath
);
}
if (contents.includes('/// <reference types="react" />')) {
succeededAdditionalChecks = false;
console.error(
"❗ %s contains a reference to the global `React` type!/n" +
'Use `import type * as ReactTypes from "react";` instead',
extractorConfig.reportFilePath
);
if (fs.existsSync(extractorConfig.reportFilePath)) {
const contents = readFileSync(extractorConfig.reportFilePath, "utf8");
if (contents.includes("rehackt")) {
succeededAdditionalChecks = false;
console.error(
"❗ %s contains a reference to the `rehackt` package!",
extractorConfig.reportFilePath
);
}
if (contents.includes('/// <reference types="react" />')) {
succeededAdditionalChecks = false;
console.error(
"❗ %s contains a reference to the global `React` type!/n" +
'Use `import type * as ReactTypes from "react";` instead',
extractorConfig.reportFilePath
);
}
}

if (extractorResult.succeeded && succeededAdditionalChecks) {
Expand All @@ -115,4 +147,4 @@ map((entryPoint: { dirs: string[] }) => {
}
process.exitCode = 1;
}
});
}
2 changes: 1 addition & 1 deletion docs/shared/ApiDoc/DocBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export function Example({
if (!value) return null;
return (
<MaybeCollapsible collapsible={collapsible}>
<b>{mdToReact(value)}</b>
{mdToReact(value)}
</MaybeCollapsible>
);
}
Expand Down
7 changes: 6 additions & 1 deletion docs/shared/ApiDoc/PropertySignatureTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,12 @@ export function PropertySignatureTable({
</MDX.inlineCode>
</GridItem>
<GridItem className="cell" fontSize="md" lineHeight="base">
<DocBlock canonicalReference={property.canonicalReference} />
<DocBlock
canonicalReference={property.canonicalReference}
summary
remarks
remarkCollapsible
/>
</GridItem>
</React.Fragment>
))}
Expand Down
126 changes: 126 additions & 0 deletions docs/source/caching/memory-management.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
---
title: Memory management
api_doc:
- "@apollo/client!CacheSizes:interface"
- "@apollo/client!ApolloClient:class"
subtitle: Learn how to choose and set custom cache sizes
description: Learn how to choose and set custom cache sizes with Apollo Client.
minVersion: 3.9.0
---

import { Remarks, PropertySignatureTable, Example } from '../../shared/ApiDoc';

## Cache Sizes

For better performance, Apollo Client caches (or, in other words, memoizes) many
internally calculated values.
In most cases, these values are cached in [weak caches](https://en.wikipedia.org/wiki/Weak_reference), which means that if the
source object is garbage-collected, the cached value will be garbage-collected,
too.

These caches are also Least Recently Used (LRU) caches, meaning that if the cache is full,
the least recently used value will be garbage-collected.

Depending on your application, you might want to tweak the cache size to fit your
needs.

You can set your cache size [before (recommended)](#setting-cache-sizes-before-loading-the-apollo-client-library) or [after](#adjusting-cache-sizes-after-loading-the-apollo-client-library) loading the Apollo Client library.

### Setting cache sizes before loading the Apollo Client library

Setting cache sizes before loading the Apollo Client library is recommended because some caches are already initialized when the library is loaded. Changed cache sizes only
affect caches created after the fact, so you'd have to write additional runtime code to recreate these caches after changing their size.

```ts
import type { CacheSizes } from '@apollo/client/utilities';

globalThis[Symbol.for("apollo.cacheSize")] = {
parser: 100,
"fragmentRegistry.lookup": 500
} satisfies Partial<CacheSizes>
```

### Adjusting cache sizes after loading the Apollo Client library

You can also adjust cache sizes after loading the library.

```js
import { cacheSizes } from '@apollo/client/utilities';
import { print } from '@apollo/client'

cacheSizes.print = 100;
// cache sizes changed this way will only take effect for caches
// created after the cache size has been changed, so we need to
// reset the cache for it to be effective

print.reset();
```

### Choosing appropriate cache sizes

<Remarks
canonicalReference="@apollo/client!CacheSizes:interface"
/>

To choose good sizes for our memoization caches, you need to know what they
use as source values, and have a general understanding of the data flow inside of
Apollo Client.

For most memoized values, the source value is a parsed GraphQL document&mdash;
a `DocumentNode`. There are two types:

* **User-supplied `DocumentNode`s** are created
by the user, for example by using the `gql` template literal tag.
This is the `QUERY`, `MUTATION`, or `SUBSCRIPTION` argument passed
into a [`useQuery` hook](../data/queries/#usequery-api) or as the `query` option to `client.query`.
* **Transformed `DocumentNode`s** are derived from
user-supplied `DocumentNode`s, for example, by applying [`DocumentTransform`s](../data/document-transforms/) to them.

As a rule of thumb, you should set the cache sizes for caches using a transformed
`DocumentNode` at least to the same size as for caches using a user-supplied
`DocumentNode`. If your application uses a custom `DocumentTransform` that does
not always transform the same input to the same output, you should set the cache
size for caches using a Transformed `DocumentNode` to a higher value than for
caches using a user-supplied `DocumentNode`.

By default, Apollo Client uses a base value of 1000 cached objects for caches using
user-supplied `DocumentNode` instances, and scales other cache sizes relative
to that. For example, the default base value of 1000 for user-provided `DocumentNode`s would scale to 2000, 4000, etc. for transformed `DocumentNode`s, depending on the transformation performed.

This base value should be plenty for most applications, but you can tweak them if you have different requirements.

#### Measuring cache usage

Since estimating appropriate cache sizes for your application can be hard, Apollo Client
exposes an API for cache usage measurement.<br />
This way, you can click around in your application and then take a look at the
actual usage of the memoizing caches.

Keep in mind that this API is primarily meant for usage with the Apollo DevTools
(an integration is coming soon), and the API may change at any
point in time.<br />
It is also only included in development builds, not in production builds.

<Note>

The cache usage API is only meant for manual measurements. Don't rely on it in production code or tests.

</Note>

<Example
canonicalReference="@apollo/client!ApolloClient#getMemoryInternals:member"
index={0}
/>

<Example
collapsible
canonicalReference="@apollo/client!ApolloClient#getMemoryInternals:member"
index={1}
/>

### Cache options

<PropertySignatureTable
canonicalReference="@apollo/client!CacheSizes:interface"
properties
/>
Loading