From ff5a332ff8b190c418df25371e36719d70061ebe Mon Sep 17 00:00:00 2001 From: Lenz Weber-Tronic Date: Wed, 20 Dec 2023 19:10:49 +0100 Subject: [PATCH] add deprecation warnings for HOC and Render Prop docblocks (#11443) * add deprecation warnings for HOC docblocks * changeset * api-extractor * also add render prop components * api report --- .api-reports/api-report-react_components.md | 6 +++--- .api-reports/api-report-react_hoc.md | 10 +++++----- .changeset/chatty-comics-yawn.md | 8 ++++++++ src/react/components/Mutation.tsx | 6 ++++++ src/react/components/Query.tsx | 6 ++++++ src/react/components/Subscription.tsx | 6 ++++++ src/react/hoc/graphql.tsx | 5 +++++ src/react/hoc/mutation-hoc.tsx | 5 +++++ src/react/hoc/query-hoc.tsx | 5 +++++ src/react/hoc/subscription-hoc.tsx | 5 +++++ src/react/hoc/withApollo.tsx | 5 +++++ 11 files changed, 59 insertions(+), 8 deletions(-) create mode 100644 .changeset/chatty-comics-yawn.md diff --git a/.api-reports/api-report-react_components.md b/.api-reports/api-report-react_components.md index 2b4d74e4b5e..0775e0c9cbb 100644 --- a/.api-reports/api-report-react_components.md +++ b/.api-reports/api-report-react_components.md @@ -946,7 +946,7 @@ type Modifiers = Record> = Partia [FieldName in keyof T]: Modifier>>; }>; -// @public (undocumented) +// @public @deprecated (undocumented) export function Mutation(props: MutationComponentOptions): ReactTypes.JSX.Element | null; // @public (undocumented) @@ -1218,7 +1218,7 @@ type OperationVariables = Record; // @public (undocumented) type Path = ReadonlyArray; -// @public (undocumented) +// @public @deprecated (undocumented) export function Query(props: QueryComponentOptions): ReactTypes.JSX.Element | null; // @public (undocumented) @@ -1624,7 +1624,7 @@ type SubscribeToMoreOptions(props: SubscriptionComponentOptions): ReactTypes.JSX.Element | null; // @public (undocumented) diff --git a/.api-reports/api-report-react_hoc.md b/.api-reports/api-report-react_hoc.md index 40b988534e5..ca318274946 100644 --- a/.api-reports/api-report-react_hoc.md +++ b/.api-reports/api-report-react_hoc.md @@ -756,7 +756,7 @@ const getApolloClientMemoryInternals: (() => { }; }) | undefined; -// @public (undocumented) +// @public @deprecated (undocumented) export function graphql> & Partial>>(document: DocumentNode, operationOptions?: OperationOption): (WrappedComponent: ReactTypes.ComponentType) => ReactTypes.ComponentClass; // @public (undocumented) @@ -1674,7 +1674,7 @@ interface WatchQueryOptions(WrappedComponent: ReactTypes.ComponentType>>, operationOptions?: OperationOption): ReactTypes.ComponentClass>; // @public (undocumented) @@ -1682,13 +1682,13 @@ export type WithApolloClient

= P & { client?: ApolloClient; }; -// @public (undocumented) +// @public @deprecated (undocumented) export function withMutation = {}, TGraphQLVariables extends OperationVariables = {}, TChildProps = MutateProps, TContext extends Record = DefaultContext, TCache extends ApolloCache = ApolloCache>(document: DocumentNode, operationOptions?: OperationOption): (WrappedComponent: ReactTypes.ComponentType) => ReactTypes.ComponentClass; -// @public (undocumented) +// @public @deprecated (undocumented) export function withQuery = Record, TData extends object = {}, TGraphQLVariables extends object = {}, TChildProps extends object = DataProps>(document: DocumentNode, operationOptions?: OperationOption): (WrappedComponent: ReactTypes.ComponentType) => ReactTypes.ComponentClass; -// @public (undocumented) +// @public @deprecated (undocumented) export function withSubscription>(document: DocumentNode, operationOptions?: OperationOption): (WrappedComponent: ReactTypes.ComponentType) => ReactTypes.ComponentClass; // Warnings were encountered during analysis: diff --git a/.changeset/chatty-comics-yawn.md b/.changeset/chatty-comics-yawn.md new file mode 100644 index 00000000000..b50a939eda2 --- /dev/null +++ b/.changeset/chatty-comics-yawn.md @@ -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. diff --git a/src/react/components/Mutation.tsx b/src/react/components/Mutation.tsx index 8dca6889f7d..ff122a7e648 100644 --- a/src/react/components/Mutation.tsx +++ b/src/react/components/Mutation.tsx @@ -5,6 +5,12 @@ import type { OperationVariables } from "../../core/index.js"; import type { MutationComponentOptions } from "./types.js"; import { useMutation } from "../hooks/index.js"; +/** + * @deprecated + * Official support for React Apollo render prop components ended in March 2020. + * This library is still included in the `@apollo/client` package, + * but it no longer receives feature updates or bug fixes. + */ export function Mutation( props: MutationComponentOptions ): ReactTypes.JSX.Element | null { diff --git a/src/react/components/Query.tsx b/src/react/components/Query.tsx index 119696f3973..428207784c7 100644 --- a/src/react/components/Query.tsx +++ b/src/react/components/Query.tsx @@ -5,6 +5,12 @@ import type { OperationVariables } from "../../core/index.js"; import type { QueryComponentOptions } from "./types.js"; import { useQuery } from "../hooks/index.js"; +/** + * @deprecated + * Official support for React Apollo render prop components ended in March 2020. + * This library is still included in the `@apollo/client` package, + * but it no longer receives feature updates or bug fixes. + */ export function Query< TData = any, TVariables extends OperationVariables = OperationVariables, diff --git a/src/react/components/Subscription.tsx b/src/react/components/Subscription.tsx index 76dda1a6241..59d694156a5 100644 --- a/src/react/components/Subscription.tsx +++ b/src/react/components/Subscription.tsx @@ -5,6 +5,12 @@ import type { OperationVariables } from "../../core/index.js"; import type { SubscriptionComponentOptions } from "./types.js"; import { useSubscription } from "../hooks/index.js"; +/** + * @deprecated + * Official support for React Apollo render prop components ended in March 2020. + * This library is still included in the `@apollo/client` package, + * but it no longer receives feature updates or bug fixes. + */ export function Subscription< TData = any, TVariables extends OperationVariables = OperationVariables, diff --git a/src/react/hoc/graphql.tsx b/src/react/hoc/graphql.tsx index 1a770aae04e..181bb5a951e 100644 --- a/src/react/hoc/graphql.tsx +++ b/src/react/hoc/graphql.tsx @@ -8,6 +8,11 @@ import { withSubscription } from "./subscription-hoc.js"; import type { OperationOption, DataProps, MutateProps } from "./types.js"; import type { OperationVariables } from "../../core/index.js"; +/** + * @deprecated + * Official support for React Apollo higher order components ended in March 2020. + * This library is still included in the `@apollo/client` package, but it no longer receives feature updates or bug fixes. + */ export function graphql< TProps extends TGraphQLVariables | {} = {}, TData extends object = {}, diff --git a/src/react/hoc/mutation-hoc.tsx b/src/react/hoc/mutation-hoc.tsx index 472cf783106..2620f46ff81 100644 --- a/src/react/hoc/mutation-hoc.tsx +++ b/src/react/hoc/mutation-hoc.tsx @@ -21,6 +21,11 @@ import { import type { OperationOption, OptionProps, MutateProps } from "./types.js"; import type { ApolloCache } from "../../core/index.js"; +/** + * @deprecated + * Official support for React Apollo higher order components ended in March 2020. + * This library is still included in the `@apollo/client` package, but it no longer receives feature updates or bug fixes. + */ export function withMutation< TProps extends TGraphQLVariables | {} = {}, TData extends Record = {}, diff --git a/src/react/hoc/query-hoc.tsx b/src/react/hoc/query-hoc.tsx index 935645c5e44..cdefd397916 100644 --- a/src/react/hoc/query-hoc.tsx +++ b/src/react/hoc/query-hoc.tsx @@ -15,6 +15,11 @@ import { } from "./hoc-utils.js"; import type { OperationOption, OptionProps, DataProps } from "./types.js"; +/** + * @deprecated + * Official support for React Apollo higher order components ended in March 2020. + * This library is still included in the `@apollo/client` package, but it no longer receives feature updates or bug fixes. + */ export function withQuery< TProps extends TGraphQLVariables | Record = Record, TData extends object = {}, diff --git a/src/react/hoc/subscription-hoc.tsx b/src/react/hoc/subscription-hoc.tsx index f3218a00a0e..bb11060aaf7 100644 --- a/src/react/hoc/subscription-hoc.tsx +++ b/src/react/hoc/subscription-hoc.tsx @@ -15,6 +15,11 @@ import { } from "./hoc-utils.js"; import type { OperationOption, OptionProps, DataProps } from "./types.js"; +/** + * @deprecated + * Official support for React Apollo higher order components ended in March 2020. + * This library is still included in the `@apollo/client` package, but it no longer receives feature updates or bug fixes. + */ export function withSubscription< TProps extends TGraphQLVariables | {} = {}, TData extends object = {}, diff --git a/src/react/hoc/withApollo.tsx b/src/react/hoc/withApollo.tsx index 3b73c1f692d..54cb7c67be9 100644 --- a/src/react/hoc/withApollo.tsx +++ b/src/react/hoc/withApollo.tsx @@ -10,6 +10,11 @@ function getDisplayName

(WrappedComponent: ReactTypes.ComponentType

) { return WrappedComponent.displayName || WrappedComponent.name || "Component"; } +/** + * @deprecated + * Official support for React Apollo higher order components ended in March 2020. + * This library is still included in the `@apollo/client` package, but it no longer receives feature updates or bug fixes. + */ export function withApollo( WrappedComponent: ReactTypes.ComponentType< WithApolloClient>