From 0d52d13b2c148f9c736eadf3ad587f9d6b5fed3a Mon Sep 17 00:00:00 2001 From: Jerel Miller Date: Tue, 28 Nov 2023 21:15:28 -0700 Subject: [PATCH 1/5] Use proper tsdoc format for refetch doc in ObservableQuery --- src/core/ObservableQuery.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/ObservableQuery.ts b/src/core/ObservableQuery.ts index bda85a543a7..6018512d251 100644 --- a/src/core/ObservableQuery.ts +++ b/src/core/ObservableQuery.ts @@ -364,7 +364,7 @@ export class ObservableQuery< * Update the variables of this observable query, and fetch the new results. * This method should be preferred over `setVariables` in most use cases. * - * @param variables: The new set of variables. If there are missing variables, + * @param variables - The new set of variables. If there are missing variables, * the previous values of those variables will be used. */ public refetch( From b0ded19901229e4c1447f4fd80913d1f8009e055 Mon Sep 17 00:00:00 2001 From: Jerel Miller Date: Tue, 28 Nov 2023 21:24:27 -0700 Subject: [PATCH 2/5] Add tsdoc to fetchMore function in ObservableQuery --- src/core/ObservableQuery.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/core/ObservableQuery.ts b/src/core/ObservableQuery.ts index 6018512d251..f6b2e8dc413 100644 --- a/src/core/ObservableQuery.ts +++ b/src/core/ObservableQuery.ts @@ -412,6 +412,14 @@ Did you mean to call refetch(variables) instead of refetch({ variables })?`, return this.reobserve(reobserveOptions, NetworkStatus.refetch); } + /** + * A function that helps you fetch the next set of results for a [paginated + * list field](https://www.apollographql.com/docs/react/pagination/core-api/). + * + * @param fetchMoreOptions - Options that are shallow merged with existing + * options to determine how to fetch the result. Pass an `updateQuery` option + * to instruct Apollo Client with how to write the value to the cache. + */ public fetchMore< TFetchData = TData, TFetchVars extends OperationVariables = TVariables, From 8e85716a99fe2c6e8e2668ca95c8e7aa3887e3ee Mon Sep 17 00:00:00 2001 From: Jerel Miller Date: Tue, 28 Nov 2023 21:26:14 -0700 Subject: [PATCH 3/5] Add inheritDoc comments to fetchMore/refetch in suspense hooks --- src/react/hooks/useBackgroundQuery.ts | 2 ++ src/react/hooks/useLoadableQuery.ts | 2 ++ src/react/hooks/useSuspenseQuery.ts | 2 ++ 3 files changed, 6 insertions(+) diff --git a/src/react/hooks/useBackgroundQuery.ts b/src/react/hooks/useBackgroundQuery.ts index 20b2e978aa7..8c11560f700 100644 --- a/src/react/hooks/useBackgroundQuery.ts +++ b/src/react/hooks/useBackgroundQuery.ts @@ -23,7 +23,9 @@ export type UseBackgroundQueryResult< TData = unknown, TVariables extends OperationVariables = OperationVariables, > = { + /** {@inheritDoc @apollo/client!ObservableQuery#fetchMore:member(1)} */ fetchMore: FetchMoreFunction; + /** {@inheritDoc @apollo/client!ObservableQuery#refetch:member(1)} */ refetch: RefetchFunction; }; diff --git a/src/react/hooks/useLoadableQuery.ts b/src/react/hooks/useLoadableQuery.ts index 2ec551bf26e..a91b1cb16ed 100644 --- a/src/react/hooks/useLoadableQuery.ts +++ b/src/react/hooks/useLoadableQuery.ts @@ -46,7 +46,9 @@ export type UseLoadableQueryResult< LoadQueryFunction, QueryReference | null, { + /** {@inheritDoc @apollo/client!ObservableQuery#fetchMore:member(1)} */ fetchMore: FetchMoreFunction; + /** {@inheritDoc @apollo/client!ObservableQuery#refetch:member(1)} */ refetch: RefetchFunction; reset: ResetFunction; }, diff --git a/src/react/hooks/useSuspenseQuery.ts b/src/react/hooks/useSuspenseQuery.ts index ed203d4cfee..2c78e78808e 100644 --- a/src/react/hooks/useSuspenseQuery.ts +++ b/src/react/hooks/useSuspenseQuery.ts @@ -34,8 +34,10 @@ export interface UseSuspenseQueryResult< client: ApolloClient; data: TData; error: ApolloError | undefined; + /** {@inheritDoc @apollo/client!ObservableQuery#fetchMore:member(1)} */ fetchMore: FetchMoreFunction; networkStatus: NetworkStatus; + /** {@inheritDoc @apollo/client!ObservableQuery#refetch:member(1)} */ refetch: RefetchFunction; subscribeToMore: SubscribeToMoreFunction; } From 57034787c31ba929b888f8add1480bee54b7534f Mon Sep 17 00:00:00 2001 From: Jerel Miller Date: Tue, 28 Nov 2023 21:26:51 -0700 Subject: [PATCH 4/5] Add tsdoc to reset function in useLoadableQuery --- src/react/hooks/useLoadableQuery.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/react/hooks/useLoadableQuery.ts b/src/react/hooks/useLoadableQuery.ts index a91b1cb16ed..6760a08e8c0 100644 --- a/src/react/hooks/useLoadableQuery.ts +++ b/src/react/hooks/useLoadableQuery.ts @@ -50,6 +50,9 @@ export type UseLoadableQueryResult< fetchMore: FetchMoreFunction; /** {@inheritDoc @apollo/client!ObservableQuery#refetch:member(1)} */ refetch: RefetchFunction; + /** + * Disposes of the `queryRef` and sets it back to `null`. + */ reset: ResetFunction; }, ]; From 9c05d09e21f06949b44e2144db2f8db3af285350 Mon Sep 17 00:00:00 2001 From: Jerel Miller Date: Tue, 28 Nov 2023 21:36:43 -0700 Subject: [PATCH 5/5] Add tsdoc to useSuspenseQuery --- src/react/hooks/useSuspenseQuery.ts | 32 +++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/react/hooks/useSuspenseQuery.ts b/src/react/hooks/useSuspenseQuery.ts index 2c78e78808e..bd1d0053041 100644 --- a/src/react/hooks/useSuspenseQuery.ts +++ b/src/react/hooks/useSuspenseQuery.ts @@ -31,14 +31,46 @@ export interface UseSuspenseQueryResult< TData = unknown, TVariables extends OperationVariables = OperationVariables, > { + /** + * The instance of Apollo Client that executed the query. + * + * Can be useful for manually executing followup queries or writing data to + * the cache. + */ client: ApolloClient; + /** + * An object containing the result of your GraphQL query after it completes. + * + * This value might be `undefined` if a query results in one or more errors + * (depending on the query's `errorPolicy`). + */ data: TData; + /** + * If the query produces one or more errors, this object contains either an + * array of `graphQLErrors` or a single `networkError`. Otherwise, this value + * is `undefined`. + * + * This property can be ignored when using the default `errorPolicy` or an + * `errorPolicy` of `none`. The hook will throw the error instead of setting + * this property. + */ error: ApolloError | undefined; /** {@inheritDoc @apollo/client!ObservableQuery#fetchMore:member(1)} */ fetchMore: FetchMoreFunction; + /** + * A number indicating the current network state of the query's associated + * request. [See possible values](https://github.com/apollographql/apollo-client/blob/d96f4578f89b933c281bb775a39503f6cdb59ee8/src/core/networkStatus.ts#L4). + */ networkStatus: NetworkStatus; /** {@inheritDoc @apollo/client!ObservableQuery#refetch:member(1)} */ refetch: RefetchFunction; + /** + * A function that enables you to execute a [subscription](https://www.apollographql.com/docs/react/data/subscriptions/), + * usually to subscribe to specific fields that were included in the query. + * + * This function returns another function that you can call to terminate the + * subscription. + */ subscribeToMore: SubscribeToMoreFunction; }