Skip to content

Commit

Permalink
Merge branch 'release-3.9' into jerel/remove-retain-loadable-query
Browse files Browse the repository at this point in the history
  • Loading branch information
jerelmiller authored Dec 20, 2023
2 parents 2e8109a + de5b878 commit a4da26c
Show file tree
Hide file tree
Showing 39 changed files with 743 additions and 243 deletions.
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
8 changes: 3 additions & 5 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 Expand Up @@ -946,7 +944,7 @@ type Modifiers<T extends Record<string, any> = Record<string, unknown>> = Partia
[FieldName in keyof T]: Modifier<StoreObjectValueMaybeReference<Exclude<T[FieldName], undefined>>>;
}>;

// @public (undocumented)
// @public @deprecated (undocumented)
export function Mutation<TData = any, TVariables = OperationVariables>(props: MutationComponentOptions<TData, TVariables>): ReactTypes.JSX.Element | null;

// @public (undocumented)
Expand Down Expand Up @@ -1218,7 +1216,7 @@ type OperationVariables = Record<string, any>;
// @public (undocumented)
type Path = ReadonlyArray<string | number>;

// @public (undocumented)
// @public @deprecated (undocumented)
export function Query<TData = any, TVariables extends OperationVariables = OperationVariables>(props: QueryComponentOptions<TData, TVariables>): ReactTypes.JSX.Element | null;

// @public (undocumented)
Expand Down Expand Up @@ -1624,7 +1622,7 @@ type SubscribeToMoreOptions<TData = any, TSubscriptionVariables = OperationVaria
context?: DefaultContext;
};

// @public (undocumented)
// @public @deprecated (undocumented)
export function Subscription<TData = any, TVariables extends OperationVariables = OperationVariables>(props: SubscriptionComponentOptions<TData, TVariables>): ReactTypes.JSX.Element | null;

// @public (undocumented)
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
12 changes: 5 additions & 7 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 Expand Up @@ -756,7 +754,7 @@ const getApolloClientMemoryInternals: (() => {
};
}) | undefined;

// @public (undocumented)
// @public @deprecated (undocumented)
export function graphql<TProps extends TGraphQLVariables | {} = {}, TData extends object = {}, TGraphQLVariables extends OperationVariables = {}, TChildProps extends object = Partial<DataProps<TData, TGraphQLVariables>> & Partial<MutateProps<TData, TGraphQLVariables>>>(document: DocumentNode, operationOptions?: OperationOption<TProps, TData, TGraphQLVariables, TChildProps>): (WrappedComponent: ReactTypes.ComponentType<TProps & TChildProps>) => ReactTypes.ComponentClass<TProps>;

// @public (undocumented)
Expand Down Expand Up @@ -1674,21 +1672,21 @@ interface WatchQueryOptions<TVariables extends OperationVariables = OperationVar
variables?: TVariables;
}

// @public (undocumented)
// @public @deprecated (undocumented)
export function withApollo<TProps, TResult = any>(WrappedComponent: ReactTypes.ComponentType<WithApolloClient<Omit<TProps, "client">>>, operationOptions?: OperationOption<TProps, TResult>): ReactTypes.ComponentClass<Omit<TProps, "client">>;

// @public (undocumented)
export type WithApolloClient<P> = P & {
client?: ApolloClient<any>;
};

// @public (undocumented)
// @public @deprecated (undocumented)
export function withMutation<TProps extends TGraphQLVariables | {} = {}, TData extends Record<string, any> = {}, TGraphQLVariables extends OperationVariables = {}, TChildProps = MutateProps<TData, TGraphQLVariables>, TContext extends Record<string, any> = DefaultContext, TCache extends ApolloCache<any> = ApolloCache<any>>(document: DocumentNode, operationOptions?: OperationOption<TProps, TData, TGraphQLVariables, TChildProps>): (WrappedComponent: ReactTypes.ComponentType<TProps & TChildProps>) => ReactTypes.ComponentClass<TProps>;

// @public (undocumented)
// @public @deprecated (undocumented)
export function withQuery<TProps extends TGraphQLVariables | Record<string, any> = Record<string, any>, TData extends object = {}, TGraphQLVariables extends object = {}, TChildProps extends object = DataProps<TData, TGraphQLVariables>>(document: DocumentNode, operationOptions?: OperationOption<TProps, TData, TGraphQLVariables, TChildProps>): (WrappedComponent: ReactTypes.ComponentType<TProps & TChildProps>) => ReactTypes.ComponentClass<TProps>;

// @public (undocumented)
// @public @deprecated (undocumented)
export function withSubscription<TProps extends TGraphQLVariables | {} = {}, TData extends object = {}, TGraphQLVariables extends object = {}, TChildProps extends object = DataProps<TData, TGraphQLVariables>>(document: DocumentNode, operationOptions?: OperationOption<TProps, TData, TGraphQLVariables, TChildProps>): (WrappedComponent: ReactTypes.ComponentType<TProps & TChildProps>) => ReactTypes.ComponentClass<TProps>;

// Warnings were encountered during analysis:
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
8 changes: 8 additions & 0 deletions .changeset/chatty-comics-yawn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@apollo/client": patch
---

Adds a deprecation warning to the HOC and render prop APIs.

The HOC and render prop APIs have already been deprecated since 2020,
but we previously didn't have a @deprecated tag in the DocBlocks.
13 changes: 13 additions & 0 deletions .changeset/curvy-seas-hope.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
"@apollo/client": minor
---

Simplify RetryLink, fix potential memory leak

Historically, `RetryLink` would keep a `values` array of all previous values,
in case the operation would get an additional subscriber at a later point in time.
In practice, this could lead to a memory leak (#11393) and did not serve any
further purpose, as the resulting observable would only be subscribed to by
Apollo Client itself, and only once - it would be wrapped in a `Concast` before
being exposed to the user, and that `Concast` would handle subscribers on its
own.
5 changes: 5 additions & 0 deletions .changeset/smooth-plums-shout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@apollo/client": patch
---

ObservableQuery: prevent reporting results of previous queries if the variables changed since
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
Loading

0 comments on commit a4da26c

Please sign in to comment.