From 1c8cbf9d8f87e05ad0b080d81f4d1ab54398db4d Mon Sep 17 00:00:00 2001 From: Maikel Date: Fri, 29 Nov 2024 14:14:07 +0100 Subject: [PATCH 1/2] feat: mutate shortcut --- docs/client-react-streaming.registerapolloclient.md | 3 ++- ...rimental-nextjs-app-support.registerapolloclient.md | 3 ++- .../src/registerApolloClient.tsx | 10 ++++++---- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/docs/client-react-streaming.registerapolloclient.md b/docs/client-react-streaming.registerapolloclient.md index e9887c8c..dac7657c 100644 --- a/docs/client-react-streaming.registerapolloclient.md +++ b/docs/client-react-streaming.registerapolloclient.md @@ -14,6 +14,7 @@ Ensures that you can always access the same instance of ApolloClient during RSC declare function registerApolloClient> | ApolloClient$1>(makeClient: () => ApolloClientOrPromise): { getClient: () => ApolloClientOrPromise; query: Awaited["query"]; + mutate: Awaited["mutate"]; PreloadQuery: PreloadQueryComponent; }; ``` @@ -53,7 +54,7 @@ makeClient **Returns:** -{ getClient: () => ApolloClientOrPromise; query: Awaited<ApolloClientOrPromise>\["query"\]; PreloadQuery: [PreloadQueryComponent](./client-react-streaming.preloadquerycomponent.md); } +{ getClient: () => ApolloClientOrPromise; query: Awaited<ApolloClientOrPromise>\["query"\]; mutate: Awaited<ApolloClientOrPromise>\["mutate"\]; PreloadQuery: [PreloadQueryComponent](./client-react-streaming.preloadquerycomponent.md); } ## Example diff --git a/docs/experimental-nextjs-app-support.registerapolloclient.md b/docs/experimental-nextjs-app-support.registerapolloclient.md index ee673b3e..2f334a12 100644 --- a/docs/experimental-nextjs-app-support.registerapolloclient.md +++ b/docs/experimental-nextjs-app-support.registerapolloclient.md @@ -14,6 +14,7 @@ Ensures that you can always access the same instance of ApolloClient during RSC declare function registerApolloClient> | ApolloClient$1>(makeClient: () => ApolloClientOrPromise): { getClient: () => ApolloClientOrPromise; query: Awaited["query"]; + mutate: Awaited["mutate"]; PreloadQuery: PreloadQueryComponent; }; ``` @@ -53,7 +54,7 @@ makeClient **Returns:** -{ getClient: () => ApolloClientOrPromise; query: Awaited<ApolloClientOrPromise>\["query"\]; PreloadQuery: [PreloadQueryComponent](./experimental-nextjs-app-support.preloadquerycomponent.md); } +{ getClient: () => ApolloClientOrPromise; query: Awaited<ApolloClientOrPromise>\["query"\]; mutate: Awaited<ApolloClientOrPromise>\["mutate"\]; PreloadQuery: [PreloadQueryComponent](./experimental-nextjs-app-support.preloadquerycomponent.md); } ## Example diff --git a/packages/client-react-streaming/src/registerApolloClient.tsx b/packages/client-react-streaming/src/registerApolloClient.tsx index 3bb9e52e..30d4c1f7 100644 --- a/packages/client-react-streaming/src/registerApolloClient.tsx +++ b/packages/client-react-streaming/src/registerApolloClient.tsx @@ -41,6 +41,7 @@ export function registerApolloClient< ): { getClient: () => ApolloClientOrPromise; query: Awaited["query"]; + mutate: Awaited["mutate"]; /** * Preloads data in React Server Components to be hydrated * in Client Components. @@ -90,6 +91,7 @@ export function registerApolloClient< return { getClient, query: async (...args) => (await getClient()).query(...args), + mutate: async (...args) => (await getClient()).mutate(...args), PreloadQuery, }; } @@ -152,10 +154,10 @@ return a new instance every time \`makeClient\` is called. export interface PreloadQueryProps extends PreloadQueryOptions { children: - | ReactNode - | (( - queryRef: TransportedQueryRef, NoInfer> - ) => ReactNode); + | ReactNode + | (( + queryRef: TransportedQueryRef, NoInfer> + ) => ReactNode); } /** From 07efb091f7eeada3d1d182c54c25381907d34d45 Mon Sep 17 00:00:00 2001 From: Maikel Date: Fri, 29 Nov 2024 14:16:21 +0100 Subject: [PATCH 2/2] revert formatting --- .../client-react-streaming/src/registerApolloClient.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/client-react-streaming/src/registerApolloClient.tsx b/packages/client-react-streaming/src/registerApolloClient.tsx index 30d4c1f7..0cac12ca 100644 --- a/packages/client-react-streaming/src/registerApolloClient.tsx +++ b/packages/client-react-streaming/src/registerApolloClient.tsx @@ -154,10 +154,10 @@ return a new instance every time \`makeClient\` is called. export interface PreloadQueryProps extends PreloadQueryOptions { children: - | ReactNode - | (( - queryRef: TransportedQueryRef, NoInfer> - ) => ReactNode); + | ReactNode + | (( + queryRef: TransportedQueryRef, NoInfer> + ) => ReactNode); } /**