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

Add tsdoc for refetch, fetchMore and other returned values for suspense hooks #11394

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 9 additions & 1 deletion src/core/ObservableQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions src/react/hooks/useBackgroundQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ export type UseBackgroundQueryResult<
TData = unknown,
TVariables extends OperationVariables = OperationVariables,
> = {
/** {@inheritDoc @apollo/client!ObservableQuery#fetchMore:member(1)} */
fetchMore: FetchMoreFunction<TData, TVariables>;
/** {@inheritDoc @apollo/client!ObservableQuery#refetch:member(1)} */
refetch: RefetchFunction<TData, TVariables>;
};

Expand Down
5 changes: 5 additions & 0 deletions src/react/hooks/useLoadableQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,13 @@ export type UseLoadableQueryResult<
LoadQueryFunction<TVariables>,
QueryReference<TData> | null,
{
/** {@inheritDoc @apollo/client!ObservableQuery#fetchMore:member(1)} */
fetchMore: FetchMoreFunction<TData, TVariables>;
/** {@inheritDoc @apollo/client!ObservableQuery#refetch:member(1)} */
refetch: RefetchFunction<TData, TVariables>;
/**
* Disposes of the `queryRef` and sets it back to `null`.
*/
reset: ResetFunction;
},
];
Expand Down
34 changes: 34 additions & 0 deletions src/react/hooks/useSuspenseQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +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<any>;
/**
* 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<TData, TVariables>;
/**
* 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<TData, TVariables>;
/**
* 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<TData, TVariables>;
}

Expand Down
Loading