@trpc/next 10.0.0-alpha.23 → 10.0.0-alpha.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +6 -5
- package/dist/index.mjs +6 -5
- package/dist/setupNext.d.ts +39 -38
- package/dist/setupNext.d.ts.map +1 -1
- package/dist/withTRPC.d.ts +2 -2
- package/dist/withTRPC.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/setupNext.tsx +3 -1
- package/src/withTRPC.tsx +11 -8
package/dist/index.js
CHANGED
|
@@ -48,7 +48,7 @@ function transformQueryOrMutationCacheErrors(result) {
|
|
|
48
48
|
function withTRPC(opts) {
|
|
49
49
|
var getClientConfig = opts.config;
|
|
50
50
|
return function (AppOrPage) {
|
|
51
|
-
var trpc = react.createReactQueryHooks(
|
|
51
|
+
var trpc = react.createReactQueryHooks();
|
|
52
52
|
|
|
53
53
|
var WithTRPC = function WithTRPC(props) {
|
|
54
54
|
var _props$pageProps;
|
|
@@ -75,7 +75,7 @@ function withTRPC(opts) {
|
|
|
75
75
|
ssrState = _useState2$.ssrState,
|
|
76
76
|
ssrContext = _useState2$.ssrContext;
|
|
77
77
|
|
|
78
|
-
var hydratedState = trpc.useDehydratedState((_props$pageProps = props.pageProps) === null || _props$pageProps === void 0 ? void 0 : _props$pageProps.trpcState);
|
|
78
|
+
var hydratedState = trpc.useDehydratedState(trpcClient, (_props$pageProps = props.pageProps) === null || _props$pageProps === void 0 ? void 0 : _props$pageProps.trpcState);
|
|
79
79
|
return /*#__PURE__*/React__default["default"].createElement(trpc.Provider, {
|
|
80
80
|
client: trpcClient,
|
|
81
81
|
queryClient: queryClient,
|
|
@@ -193,7 +193,7 @@ function withTRPC(opts) {
|
|
|
193
193
|
mutations: dehydratedCache.mutations.map(transformQueryOrMutationCacheErrors)
|
|
194
194
|
}); // dehydrate query client's state and add it to the props
|
|
195
195
|
|
|
196
|
-
pageProps.trpcState =
|
|
196
|
+
pageProps.trpcState = trpcClient.runtime.transformer.serialize(dehydratedCacheWithErrors);
|
|
197
197
|
appTreeProps = getAppTreeProps(pageProps);
|
|
198
198
|
meta = ((_opts$responseMeta = opts.responseMeta) === null || _opts$responseMeta === void 0 ? void 0 : _opts$responseMeta.call(opts, {
|
|
199
199
|
ctx: ctx,
|
|
@@ -239,7 +239,7 @@ function withTRPC(opts) {
|
|
|
239
239
|
}
|
|
240
240
|
|
|
241
241
|
function setupTRPC(opts) {
|
|
242
|
-
var hooks = react.createReactQueryHooks(
|
|
242
|
+
var hooks = react.createReactQueryHooks(); // TODO: maybe set TSSRContext to `never` when using `WithTRPCNoSSROptions`
|
|
243
243
|
|
|
244
244
|
var _withTRPC = withTRPC(opts);
|
|
245
245
|
|
|
@@ -249,7 +249,8 @@ function setupTRPC(opts) {
|
|
|
249
249
|
useMutation: hooks.useMutation,
|
|
250
250
|
useQuery: hooks.useQuery,
|
|
251
251
|
useSubscription: hooks.useSubscription,
|
|
252
|
-
withTRPC: _withTRPC
|
|
252
|
+
withTRPC: _withTRPC,
|
|
253
|
+
queries: hooks.queries
|
|
253
254
|
};
|
|
254
255
|
}
|
|
255
256
|
|
package/dist/index.mjs
CHANGED
|
@@ -34,7 +34,7 @@ function transformQueryOrMutationCacheErrors(result) {
|
|
|
34
34
|
function withTRPC(opts) {
|
|
35
35
|
var getClientConfig = opts.config;
|
|
36
36
|
return function (AppOrPage) {
|
|
37
|
-
var trpc = createReactQueryHooks(
|
|
37
|
+
var trpc = createReactQueryHooks();
|
|
38
38
|
|
|
39
39
|
var WithTRPC = function WithTRPC(props) {
|
|
40
40
|
var _props$pageProps;
|
|
@@ -61,7 +61,7 @@ function withTRPC(opts) {
|
|
|
61
61
|
ssrState = _useState2$.ssrState,
|
|
62
62
|
ssrContext = _useState2$.ssrContext;
|
|
63
63
|
|
|
64
|
-
var hydratedState = trpc.useDehydratedState((_props$pageProps = props.pageProps) === null || _props$pageProps === void 0 ? void 0 : _props$pageProps.trpcState);
|
|
64
|
+
var hydratedState = trpc.useDehydratedState(trpcClient, (_props$pageProps = props.pageProps) === null || _props$pageProps === void 0 ? void 0 : _props$pageProps.trpcState);
|
|
65
65
|
return /*#__PURE__*/React.createElement(trpc.Provider, {
|
|
66
66
|
client: trpcClient,
|
|
67
67
|
queryClient: queryClient,
|
|
@@ -179,7 +179,7 @@ function withTRPC(opts) {
|
|
|
179
179
|
mutations: dehydratedCache.mutations.map(transformQueryOrMutationCacheErrors)
|
|
180
180
|
}); // dehydrate query client's state and add it to the props
|
|
181
181
|
|
|
182
|
-
pageProps.trpcState =
|
|
182
|
+
pageProps.trpcState = trpcClient.runtime.transformer.serialize(dehydratedCacheWithErrors);
|
|
183
183
|
appTreeProps = getAppTreeProps(pageProps);
|
|
184
184
|
meta = ((_opts$responseMeta = opts.responseMeta) === null || _opts$responseMeta === void 0 ? void 0 : _opts$responseMeta.call(opts, {
|
|
185
185
|
ctx: ctx,
|
|
@@ -225,7 +225,7 @@ function withTRPC(opts) {
|
|
|
225
225
|
}
|
|
226
226
|
|
|
227
227
|
function setupTRPC(opts) {
|
|
228
|
-
var hooks = createReactQueryHooks(
|
|
228
|
+
var hooks = createReactQueryHooks(); // TODO: maybe set TSSRContext to `never` when using `WithTRPCNoSSROptions`
|
|
229
229
|
|
|
230
230
|
var _withTRPC = withTRPC(opts);
|
|
231
231
|
|
|
@@ -235,7 +235,8 @@ function setupTRPC(opts) {
|
|
|
235
235
|
useMutation: hooks.useMutation,
|
|
236
236
|
useQuery: hooks.useQuery,
|
|
237
237
|
useSubscription: hooks.useSubscription,
|
|
238
|
-
withTRPC: _withTRPC
|
|
238
|
+
withTRPC: _withTRPC,
|
|
239
|
+
queries: hooks.queries
|
|
239
240
|
};
|
|
240
241
|
}
|
|
241
242
|
|
package/dist/setupNext.d.ts
CHANGED
|
@@ -3,49 +3,50 @@ import { NextPageContext } from 'next/types';
|
|
|
3
3
|
import { WithTRPCNoSSROptions, WithTRPCSSROptions } from './withTRPC';
|
|
4
4
|
export declare function setupTRPC<TRouter extends AnyRouter, TSSRContext extends NextPageContext = NextPageContext>(opts: WithTRPCNoSSROptions<TRouter> | WithTRPCSSROptions<TRouter>): {
|
|
5
5
|
useContext: () => import("@trpc/react").TRPCContextState<TRouter, unknown>;
|
|
6
|
-
useInfiniteQuery: <TPath_3 extends { [TPath in keyof
|
|
6
|
+
useInfiniteQuery: <TPath_3 extends (TRouter["queries"] extends infer T ? { [TPath in keyof T]: import("@trpc/server").inferProcedureInput<TRouter["queries"][TPath]> extends {
|
|
7
7
|
cursor?: any;
|
|
8
|
-
} ? TPath : never; }[keyof TRouter["
|
|
9
|
-
input: import("@trpc/server").inferProcedureInput<TRouter["
|
|
10
|
-
output: import("@trpc/server").ThenArg<ReturnType<TRouter["
|
|
11
|
-
}; }[TPath_3]["input"], "cursor">], opts?: import("@trpc/react").UseTRPCInfiniteQueryOptions<TPath_3, Omit<{ [TPath_1 in keyof
|
|
12
|
-
input: import("@trpc/server").inferProcedureInput<TRouter["
|
|
13
|
-
output: import("@trpc/server").ThenArg<ReturnType<TRouter["
|
|
14
|
-
}; }[TPath_3]["input"], "cursor">, { [TPath_1 in keyof
|
|
15
|
-
input: import("@trpc/server").inferProcedureInput<TRouter["
|
|
16
|
-
output: import("@trpc/server").ThenArg<ReturnType<TRouter["
|
|
17
|
-
}; }[TPath_3]["output"], import("@trpc/react").TRPCClientErrorLike<TRouter>> | undefined) => import("react-query").UseInfiniteQueryResult<{ [TPath_1 in keyof
|
|
18
|
-
input: import("@trpc/server").inferProcedureInput<TRouter["
|
|
19
|
-
output: import("@trpc/server").ThenArg<ReturnType<TRouter["
|
|
20
|
-
}; }[TPath_3]["output"], import("@trpc/react").TRPCClientErrorLike<TRouter>>;
|
|
21
|
-
useMutation: <TPath_1 extends keyof TRouter["
|
|
22
|
-
input: import("@trpc/server").inferProcedureInput<TRouter["
|
|
23
|
-
output: import("@trpc/server").ThenArg<ReturnType<TRouter["
|
|
24
|
-
}; }[TPath_1]["input"], import("@trpc/react").TRPCClientErrorLike<TRouter>, { [TPath_2 in keyof
|
|
25
|
-
input: import("@trpc/server").inferProcedureInput<TRouter["
|
|
26
|
-
output: import("@trpc/server").ThenArg<ReturnType<TRouter["
|
|
27
|
-
}; }[TPath_1]["output"], TContext> | undefined) => import("react-query").UseMutationResult<{ [TPath_2 in keyof
|
|
28
|
-
input: import("@trpc/server").inferProcedureInput<TRouter["
|
|
29
|
-
output: import("@trpc/server").ThenArg<ReturnType<TRouter["
|
|
30
|
-
}; }[TPath_1]["output"], import("@trpc/react").TRPCClientErrorLike<TRouter>, { [TPath_2 in keyof
|
|
31
|
-
input: import("@trpc/server").inferProcedureInput<TRouter["
|
|
32
|
-
output: import("@trpc/server").ThenArg<ReturnType<TRouter["
|
|
33
|
-
}; }[TPath_1]["input"], TContext>;
|
|
34
|
-
useQuery: <TPath_4 extends keyof TRouter["
|
|
35
|
-
input: import("@trpc/server").inferProcedureInput<TRouter["
|
|
36
|
-
output: import("@trpc/server").ThenArg<ReturnType<TRouter["
|
|
37
|
-
}; }[TPath_4]["output"], TData = { [TPath_1 in keyof
|
|
38
|
-
input: import("@trpc/server").inferProcedureInput<TRouter["
|
|
39
|
-
output: import("@trpc/server").ThenArg<ReturnType<TRouter["
|
|
40
|
-
}; }[TPath_4]["output"]>(pathAndInput: [path: TPath_4, ...args: import("@trpc/server").inferHandlerInput<TRouter["
|
|
41
|
-
input: import("@trpc/server").inferProcedureInput<TRouter["
|
|
42
|
-
output: import("@trpc/server").ThenArg<ReturnType<TRouter["
|
|
43
|
-
}; }[TPath_4]["input"], TQueryFnData, TData, import("@trpc/react").TRPCClientErrorLike<TRouter>> | undefined) => import("react-query").UseQueryResult<TData, import("@trpc/react").TRPCClientErrorLike<TRouter>>;
|
|
44
|
-
useSubscription: <TPath_2 extends keyof TRouter["
|
|
8
|
+
} ? TPath : never; } : never)[keyof TRouter["queries"]] & string>(pathAndInput: [path: TPath_3, input: Omit<(TRouter["queries"] extends infer T_1 ? { [TPath_1 in keyof T_1]: {
|
|
9
|
+
input: import("@trpc/server").inferProcedureInput<TRouter["queries"][TPath_1]>;
|
|
10
|
+
output: import("@trpc/server").ThenArg<ReturnType<TRouter["queries"][TPath_1]>>;
|
|
11
|
+
}; } : never)[TPath_3]["input"], "cursor">], opts?: import("@trpc/react").UseTRPCInfiniteQueryOptions<TPath_3, Omit<(TRouter["queries"] extends infer T_1 ? { [TPath_1 in keyof T_1]: {
|
|
12
|
+
input: import("@trpc/server").inferProcedureInput<TRouter["queries"][TPath_1]>;
|
|
13
|
+
output: import("@trpc/server").ThenArg<ReturnType<TRouter["queries"][TPath_1]>>;
|
|
14
|
+
}; } : never)[TPath_3]["input"], "cursor">, (TRouter["queries"] extends infer T_1 ? { [TPath_1 in keyof T_1]: {
|
|
15
|
+
input: import("@trpc/server").inferProcedureInput<TRouter["queries"][TPath_1]>;
|
|
16
|
+
output: import("@trpc/server").ThenArg<ReturnType<TRouter["queries"][TPath_1]>>;
|
|
17
|
+
}; } : never)[TPath_3]["output"], import("@trpc/react").TRPCClientErrorLike<TRouter>> | undefined) => import("react-query").UseInfiniteQueryResult<(TRouter["queries"] extends infer T_1 ? { [TPath_1 in keyof T_1]: {
|
|
18
|
+
input: import("@trpc/server").inferProcedureInput<TRouter["queries"][TPath_1]>;
|
|
19
|
+
output: import("@trpc/server").ThenArg<ReturnType<TRouter["queries"][TPath_1]>>;
|
|
20
|
+
}; } : never)[TPath_3]["output"], import("@trpc/react").TRPCClientErrorLike<TRouter>>;
|
|
21
|
+
useMutation: <TPath_1 extends keyof TRouter["mutations"] & string, TContext = unknown>(path: TPath_1 | [TPath_1], opts?: import("@trpc/react").UseTRPCMutationOptions<(TRouter["mutations"] extends infer T_2 ? { [TPath_2 in keyof T_2]: {
|
|
22
|
+
input: import("@trpc/server").inferProcedureInput<TRouter["mutations"][TPath_2]>;
|
|
23
|
+
output: import("@trpc/server").ThenArg<ReturnType<TRouter["mutations"][TPath_2]>>;
|
|
24
|
+
}; } : never)[TPath_1]["input"], import("@trpc/react").TRPCClientErrorLike<TRouter>, (TRouter["mutations"] extends infer T_2 ? { [TPath_2 in keyof T_2]: {
|
|
25
|
+
input: import("@trpc/server").inferProcedureInput<TRouter["mutations"][TPath_2]>;
|
|
26
|
+
output: import("@trpc/server").ThenArg<ReturnType<TRouter["mutations"][TPath_2]>>;
|
|
27
|
+
}; } : never)[TPath_1]["output"], TContext> | undefined) => import("react-query").UseMutationResult<(TRouter["mutations"] extends infer T_2 ? { [TPath_2 in keyof T_2]: {
|
|
28
|
+
input: import("@trpc/server").inferProcedureInput<TRouter["mutations"][TPath_2]>;
|
|
29
|
+
output: import("@trpc/server").ThenArg<ReturnType<TRouter["mutations"][TPath_2]>>;
|
|
30
|
+
}; } : never)[TPath_1]["output"], import("@trpc/react").TRPCClientErrorLike<TRouter>, (TRouter["mutations"] extends infer T_2 ? { [TPath_2 in keyof T_2]: {
|
|
31
|
+
input: import("@trpc/server").inferProcedureInput<TRouter["mutations"][TPath_2]>;
|
|
32
|
+
output: import("@trpc/server").ThenArg<ReturnType<TRouter["mutations"][TPath_2]>>;
|
|
33
|
+
}; } : never)[TPath_1]["input"], TContext>;
|
|
34
|
+
useQuery: <TPath_4 extends keyof TRouter["queries"] & string, TQueryFnData = (TRouter["queries"] extends infer T_1 ? { [TPath_1 in keyof T_1]: {
|
|
35
|
+
input: import("@trpc/server").inferProcedureInput<TRouter["queries"][TPath_1]>;
|
|
36
|
+
output: import("@trpc/server").ThenArg<ReturnType<TRouter["queries"][TPath_1]>>;
|
|
37
|
+
}; } : never)[TPath_4]["output"], TData = (TRouter["queries"] extends infer T_1 ? { [TPath_1 in keyof T_1]: {
|
|
38
|
+
input: import("@trpc/server").inferProcedureInput<TRouter["queries"][TPath_1]>;
|
|
39
|
+
output: import("@trpc/server").ThenArg<ReturnType<TRouter["queries"][TPath_1]>>;
|
|
40
|
+
}; } : never)[TPath_4]["output"]>(pathAndInput: [path: TPath_4, ...args: import("@trpc/server").inferHandlerInput<TRouter["queries"][TPath_4]>], opts?: import("@trpc/react").UseTRPCQueryOptions<TPath_4, (TRouter["queries"] extends infer T_1 ? { [TPath_1 in keyof T_1]: {
|
|
41
|
+
input: import("@trpc/server").inferProcedureInput<TRouter["queries"][TPath_1]>;
|
|
42
|
+
output: import("@trpc/server").ThenArg<ReturnType<TRouter["queries"][TPath_1]>>;
|
|
43
|
+
}; } : never)[TPath_4]["input"], TQueryFnData, TData, import("@trpc/react").TRPCClientErrorLike<TRouter>> | undefined) => import("react-query").UseQueryResult<TData, import("@trpc/react").TRPCClientErrorLike<TRouter>>;
|
|
44
|
+
useSubscription: <TPath_2 extends keyof TRouter["subscriptions"] & string, TOutput extends import("@trpc/server/observable").inferObservableValue<import("@trpc/server").ThenArg<ReturnType<TRouter["subscriptions"][TPath_2]>>>>(pathAndInput: [path: TPath_2, ...args: import("@trpc/server").inferHandlerInput<TRouter["subscriptions"][TPath_2]>], opts: {
|
|
45
45
|
enabled?: boolean | undefined;
|
|
46
46
|
error?: ((err: import("@trpc/react").TRPCClientErrorLike<TRouter>) => void) | undefined;
|
|
47
47
|
next: (data: TOutput) => void;
|
|
48
48
|
}) => void;
|
|
49
49
|
withTRPC: (AppOrPage: import("next/types").NextComponentType<any, any, any>) => import("next/types").NextComponentType<NextPageContext, {}, {}>;
|
|
50
|
+
queries: TRouter["queries"];
|
|
50
51
|
};
|
|
51
52
|
//# sourceMappingURL=setupNext.d.ts.map
|
package/dist/setupNext.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setupNext.d.ts","sourceRoot":"","sources":["../src/setupNext.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAY,MAAM,YAAY,CAAC;AAEhF,wBAAgB,SAAS,CACvB,OAAO,SAAS,SAAS,EACzB,WAAW,SAAS,eAAe,GAAG,eAAe,EACrD,IAAI,EAAE,oBAAoB,CAAC,OAAO,CAAC,GAAG,kBAAkB,CAAC,OAAO,CAAC
|
|
1
|
+
{"version":3,"file":"setupNext.d.ts","sourceRoot":"","sources":["../src/setupNext.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAY,MAAM,YAAY,CAAC;AAEhF,wBAAgB,SAAS,CACvB,OAAO,SAAS,SAAS,EACzB,WAAW,SAAS,eAAe,GAAG,eAAe,EACrD,IAAI,EAAE,oBAAoB,CAAC,OAAO,CAAC,GAAG,kBAAkB,CAAC,OAAO,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAelE"}
|
package/dist/withTRPC.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* https://github.com/FormidableLabs/urql/blob/main/packages/next-urql/src/with-urql-client.ts
|
|
4
4
|
*/
|
|
5
5
|
import type { CreateTRPCClientOptions } from '@trpc/client/src/internals/TRPCClient';
|
|
6
|
-
import {
|
|
6
|
+
import { TRPCClientError } from '@trpc/react';
|
|
7
7
|
import type { AnyRouter, ResponseMeta } from '@trpc/server';
|
|
8
8
|
import { NextComponentType, NextPageContext } from 'next/dist/shared/lib/utils';
|
|
9
9
|
import { QueryClient } from 'react-query';
|
|
@@ -11,7 +11,7 @@ declare type QueryClientConfig = ConstructorParameters<typeof QueryClient>[0];
|
|
|
11
11
|
export declare type WithTRPCConfig<TRouter extends AnyRouter> = CreateTRPCClientOptions<TRouter> & {
|
|
12
12
|
queryClientConfig?: QueryClientConfig;
|
|
13
13
|
};
|
|
14
|
-
interface WithTRPCOptions<TRouter extends AnyRouter>
|
|
14
|
+
interface WithTRPCOptions<TRouter extends AnyRouter> {
|
|
15
15
|
config: (info: {
|
|
16
16
|
ctx?: NextPageContext;
|
|
17
17
|
}) => WithTRPCConfig<TRouter>;
|
package/dist/withTRPC.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withTRPC.d.ts","sourceRoot":"","sources":["../src/withTRPC.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AACrF,OAAO,
|
|
1
|
+
{"version":3,"file":"withTRPC.d.ts","sourceRoot":"","sources":["../src/withTRPC.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AACrF,OAAO,EAEL,eAAe,EAIhB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,SAAS,EAAe,YAAY,EAAE,MAAM,cAAc,CAAC;AACzE,OAAO,EAGL,iBAAiB,EACjB,eAAe,EAChB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAGL,WAAW,EAGZ,MAAM,aAAa,CAAC;AAGrB,aAAK,iBAAiB,GAAG,qBAAqB,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;AAwBtE,oBAAY,cAAc,CAAC,OAAO,SAAS,SAAS,IAClD,uBAAuB,CAAC,OAAO,CAAC,GAAG;IACjC,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC,CAAC;AAEJ,UAAU,eAAe,CAAC,OAAO,SAAS,SAAS;IACjD,MAAM,EAAE,CAAC,IAAI,EAAE;QAAE,GAAG,CAAC,EAAE,eAAe,CAAA;KAAE,KAAK,cAAc,CAAC,OAAO,CAAC,CAAC;CACtE;AAED,MAAM,WAAW,kBAAkB,CAAC,OAAO,SAAS,SAAS,CAC3D,SAAQ,eAAe,CAAC,OAAO,CAAC;IAChC,GAAG,EAAE,IAAI,CAAC;IACV,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE;QACpB,GAAG,EAAE,eAAe,CAAC;QACrB,YAAY,EAAE,eAAe,CAAC,OAAO,CAAC,EAAE,CAAC;KAC1C,KAAK,YAAY,CAAC;CACpB;AACD,MAAM,WAAW,oBAAoB,CAAC,OAAO,SAAS,SAAS,CAC7D,SAAQ,eAAe,CAAC,OAAO,CAAC;IAChC,GAAG,CAAC,EAAE,KAAK,CAAC;CACb;AAED,wBAAgB,QAAQ,CACtB,OAAO,SAAS,SAAS,EACzB,WAAW,SAAS,eAAe,GAAG,eAAe,EACrD,IAAI,EAAE,oBAAoB,CAAC,OAAO,CAAC,GAAG,kBAAkB,CAAC,OAAO,CAAC,eAU9C,kBAAkB,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,KAAG,iBAAiB,CA2KxE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trpc/next",
|
|
3
|
-
"version": "10.0.0-alpha.
|
|
3
|
+
"version": "10.0.0-alpha.26",
|
|
4
4
|
"description": "tRPC Next lib",
|
|
5
5
|
"author": "KATT",
|
|
6
6
|
"license": "MIT",
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
}
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
|
-
"@trpc/client": "10.0.0-alpha.
|
|
42
|
-
"@trpc/react": "10.0.0-alpha.
|
|
43
|
-
"@trpc/server": "10.0.0-alpha.
|
|
41
|
+
"@trpc/client": "10.0.0-alpha.26",
|
|
42
|
+
"@trpc/react": "10.0.0-alpha.26",
|
|
43
|
+
"@trpc/server": "10.0.0-alpha.26",
|
|
44
44
|
"next": "*",
|
|
45
45
|
"react": ">=16.8.0",
|
|
46
46
|
"react-dom": ">=16.8.0",
|
|
@@ -51,9 +51,9 @@
|
|
|
51
51
|
"react-ssr-prepass": "^1.5.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@trpc/client": "10.0.0-alpha.
|
|
55
|
-
"@trpc/react": "10.0.0-alpha.
|
|
56
|
-
"@trpc/server": "10.0.0-alpha.
|
|
54
|
+
"@trpc/client": "10.0.0-alpha.26",
|
|
55
|
+
"@trpc/react": "10.0.0-alpha.26",
|
|
56
|
+
"@trpc/server": "10.0.0-alpha.26",
|
|
57
57
|
"@types/express": "^4.17.12",
|
|
58
58
|
"express": "^4.17.1",
|
|
59
59
|
"next": "^12.1.6",
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"publishConfig": {
|
|
66
66
|
"access": "public"
|
|
67
67
|
},
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "412d2ba0d5f857e7f7d2e0fd3af6f1334e4f108a"
|
|
69
69
|
}
|
package/src/setupNext.tsx
CHANGED
|
@@ -7,10 +7,11 @@ export function setupTRPC<
|
|
|
7
7
|
TRouter extends AnyRouter,
|
|
8
8
|
TSSRContext extends NextPageContext = NextPageContext,
|
|
9
9
|
>(opts: WithTRPCNoSSROptions<TRouter> | WithTRPCSSROptions<TRouter>) {
|
|
10
|
-
const hooks = createReactQueryHooks<TRouter>(
|
|
10
|
+
const hooks = createReactQueryHooks<TRouter>();
|
|
11
11
|
|
|
12
12
|
// TODO: maybe set TSSRContext to `never` when using `WithTRPCNoSSROptions`
|
|
13
13
|
const _withTRPC = withTRPC<TRouter, TSSRContext>(opts);
|
|
14
|
+
|
|
14
15
|
return {
|
|
15
16
|
useContext: hooks.useContext,
|
|
16
17
|
useInfiniteQuery: hooks.useInfiniteQuery,
|
|
@@ -18,5 +19,6 @@ export function setupTRPC<
|
|
|
18
19
|
useQuery: hooks.useQuery,
|
|
19
20
|
useSubscription: hooks.useSubscription,
|
|
20
21
|
withTRPC: _withTRPC,
|
|
22
|
+
queries: hooks.queries,
|
|
21
23
|
};
|
|
22
24
|
}
|
package/src/withTRPC.tsx
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import type { CreateTRPCClientOptions } from '@trpc/client/src/internals/TRPCClient';
|
|
6
6
|
import {
|
|
7
|
-
CreateReactQueryHooksOptions,
|
|
8
7
|
TRPCClient,
|
|
9
8
|
TRPCClientError,
|
|
10
9
|
TRPCClientErrorLike,
|
|
@@ -57,8 +56,7 @@ export type WithTRPCConfig<TRouter extends AnyRouter> =
|
|
|
57
56
|
queryClientConfig?: QueryClientConfig;
|
|
58
57
|
};
|
|
59
58
|
|
|
60
|
-
interface WithTRPCOptions<TRouter extends AnyRouter>
|
|
61
|
-
extends CreateReactQueryHooksOptions {
|
|
59
|
+
interface WithTRPCOptions<TRouter extends AnyRouter> {
|
|
62
60
|
config: (info: { ctx?: NextPageContext }) => WithTRPCConfig<TRouter>;
|
|
63
61
|
}
|
|
64
62
|
|
|
@@ -89,7 +87,7 @@ export function withTRPC<
|
|
|
89
87
|
ssrContext: TSSRContext;
|
|
90
88
|
};
|
|
91
89
|
return (AppOrPage: NextComponentType<any, any, any>): NextComponentType => {
|
|
92
|
-
const trpc = createReactQueryHooks<TRouter, TSSRContext>(
|
|
90
|
+
const trpc = createReactQueryHooks<TRouter, TSSRContext>();
|
|
93
91
|
|
|
94
92
|
const WithTRPC = (
|
|
95
93
|
props: AppPropsType & {
|
|
@@ -101,6 +99,7 @@ export function withTRPC<
|
|
|
101
99
|
if (props.trpc) {
|
|
102
100
|
return props.trpc;
|
|
103
101
|
}
|
|
102
|
+
|
|
104
103
|
const config = getClientConfig({});
|
|
105
104
|
const queryClient = new QueryClient(config.queryClientConfig);
|
|
106
105
|
const trpcClient = trpc.createClient(config);
|
|
@@ -113,7 +112,10 @@ export function withTRPC<
|
|
|
113
112
|
},
|
|
114
113
|
);
|
|
115
114
|
|
|
116
|
-
const hydratedState = trpc.useDehydratedState(
|
|
115
|
+
const hydratedState = trpc.useDehydratedState(
|
|
116
|
+
trpcClient,
|
|
117
|
+
props.pageProps?.trpcState,
|
|
118
|
+
);
|
|
117
119
|
|
|
118
120
|
return (
|
|
119
121
|
<trpc.Provider
|
|
@@ -215,10 +217,11 @@ export function withTRPC<
|
|
|
215
217
|
transformQueryOrMutationCacheErrors,
|
|
216
218
|
),
|
|
217
219
|
};
|
|
220
|
+
|
|
218
221
|
// dehydrate query client's state and add it to the props
|
|
219
|
-
pageProps.trpcState =
|
|
220
|
-
|
|
221
|
-
|
|
222
|
+
pageProps.trpcState = trpcClient.runtime.transformer.serialize(
|
|
223
|
+
dehydratedCacheWithErrors,
|
|
224
|
+
);
|
|
222
225
|
|
|
223
226
|
const appTreeProps = getAppTreeProps(pageProps);
|
|
224
227
|
|