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

feat: mutate shortcut #396

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion docs/client-react-streaming.registerapolloclient.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Ensures that you can always access the same instance of ApolloClient during RSC
declare function registerApolloClient<ApolloClientOrPromise extends Promise<ApolloClient$1<any>> | ApolloClient$1<any>>(makeClient: () => ApolloClientOrPromise): {
getClient: () => ApolloClientOrPromise;
query: Awaited<ApolloClientOrPromise>["query"];
mutate: Awaited<ApolloClientOrPromise>["mutate"];
PreloadQuery: PreloadQueryComponent;
};
```
Expand Down Expand Up @@ -53,7 +54,7 @@ makeClient
</tbody></table>
**Returns:**

{ getClient: () =&gt; ApolloClientOrPromise; query: Awaited&lt;ApolloClientOrPromise&gt;\["query"\]; PreloadQuery: [PreloadQueryComponent](./client-react-streaming.preloadquerycomponent.md)<!-- -->; }
{ getClient: () =&gt; ApolloClientOrPromise; query: Awaited&lt;ApolloClientOrPromise&gt;\["query"\]; mutate: Awaited&lt;ApolloClientOrPromise&gt;\["mutate"\]; PreloadQuery: [PreloadQueryComponent](./client-react-streaming.preloadquerycomponent.md)<!-- -->; }

## Example

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Ensures that you can always access the same instance of ApolloClient during RSC
declare function registerApolloClient<ApolloClientOrPromise extends Promise<ApolloClient$1<any>> | ApolloClient$1<any>>(makeClient: () => ApolloClientOrPromise): {
getClient: () => ApolloClientOrPromise;
query: Awaited<ApolloClientOrPromise>["query"];
mutate: Awaited<ApolloClientOrPromise>["mutate"];
PreloadQuery: PreloadQueryComponent;
};
```
Expand Down Expand Up @@ -53,7 +54,7 @@ makeClient
</tbody></table>
**Returns:**

{ getClient: () =&gt; ApolloClientOrPromise; query: Awaited&lt;ApolloClientOrPromise&gt;\["query"\]; PreloadQuery: [PreloadQueryComponent](./experimental-nextjs-app-support.preloadquerycomponent.md)<!-- -->; }
{ getClient: () =&gt; ApolloClientOrPromise; query: Awaited&lt;ApolloClientOrPromise&gt;\["query"\]; mutate: Awaited&lt;ApolloClientOrPromise&gt;\["mutate"\]; PreloadQuery: [PreloadQueryComponent](./experimental-nextjs-app-support.preloadquerycomponent.md)<!-- -->; }

## Example

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export function registerApolloClient<
): {
getClient: () => ApolloClientOrPromise;
query: Awaited<ApolloClientOrPromise>["query"];
mutate: Awaited<ApolloClientOrPromise>["mutate"];
/**
* Preloads data in React Server Components to be hydrated
* in Client Components.
Expand Down Expand Up @@ -90,6 +91,7 @@ export function registerApolloClient<
return {
getClient,
query: async (...args) => (await getClient()).query(...args),
mutate: async (...args) => (await getClient()).mutate(...args),
PreloadQuery,
};
}
Expand Down
Loading