@trpc/next 11.0.0-next.91 → 11.0.0-rc.329

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.
Files changed (58) hide show
  1. package/README.md +5 -5
  2. package/dist/app-dir/client.d.ts +3 -3
  3. package/dist/app-dir/client.d.ts.map +1 -1
  4. package/dist/app-dir/client.js +5 -105
  5. package/dist/app-dir/client.mjs +4 -102
  6. package/dist/app-dir/create-action-hook.d.ts +18 -6
  7. package/dist/app-dir/create-action-hook.d.ts.map +1 -1
  8. package/dist/app-dir/create-action-hook.js +108 -0
  9. package/dist/app-dir/create-action-hook.mjs +105 -0
  10. package/dist/app-dir/formDataToObject.js +34 -0
  11. package/dist/app-dir/formDataToObject.mjs +32 -0
  12. package/dist/app-dir/links/nextCache.d.ts +4 -3
  13. package/dist/app-dir/links/nextCache.d.ts.map +1 -1
  14. package/dist/app-dir/links/nextCache.js +9 -10
  15. package/dist/app-dir/links/nextCache.mjs +8 -7
  16. package/dist/app-dir/links/nextHttp.d.ts +11 -5
  17. package/dist/app-dir/links/nextHttp.d.ts.map +1 -1
  18. package/dist/app-dir/links/nextHttp.js +22 -23
  19. package/dist/app-dir/links/nextHttp.mjs +22 -21
  20. package/dist/app-dir/server.d.ts +19 -12
  21. package/dist/app-dir/server.d.ts.map +1 -1
  22. package/dist/app-dir/server.js +39 -55
  23. package/dist/app-dir/server.mjs +29 -43
  24. package/dist/app-dir/shared.d.ts +19 -13
  25. package/dist/app-dir/shared.d.ts.map +1 -1
  26. package/dist/{shared-e49b9cdc.js → app-dir/shared.js} +1 -1
  27. package/dist/{shared-f6996341.mjs → app-dir/shared.mjs} +2 -2
  28. package/dist/app-dir/types.d.ts +23 -11
  29. package/dist/app-dir/types.d.ts.map +1 -1
  30. package/dist/bundle-analysis.json +56 -44
  31. package/dist/createTRPCNext.d.ts +10 -8
  32. package/dist/createTRPCNext.d.ts.map +1 -1
  33. package/dist/createTRPCNext.js +38 -0
  34. package/dist/createTRPCNext.mjs +36 -0
  35. package/dist/index.js +4 -190
  36. package/dist/index.mjs +2 -185
  37. package/dist/ssrPrepass.d.ts +3 -0
  38. package/dist/ssrPrepass.d.ts.map +1 -0
  39. package/dist/ssrPrepass.js +139 -0
  40. package/dist/ssrPrepass.mjs +137 -0
  41. package/dist/withTRPC.d.ts +41 -13
  42. package/dist/withTRPC.d.ts.map +1 -1
  43. package/dist/withTRPC.js +86 -0
  44. package/dist/withTRPC.mjs +84 -0
  45. package/package.json +36 -25
  46. package/src/app-dir/client.ts +4 -4
  47. package/src/app-dir/create-action-hook.tsx +49 -19
  48. package/src/app-dir/links/nextCache.ts +20 -8
  49. package/src/app-dir/links/nextHttp.ts +50 -30
  50. package/src/app-dir/server.ts +86 -34
  51. package/src/app-dir/shared.ts +52 -25
  52. package/src/app-dir/types.ts +41 -29
  53. package/src/createTRPCNext.tsx +25 -16
  54. package/src/ssrPrepass.ts +185 -0
  55. package/src/withTRPC.tsx +102 -180
  56. package/ssrPrepass/index.d.ts +1 -0
  57. package/ssrPrepass/index.js +1 -0
  58. package/dist/shared-642894f4.js +0 -19
@@ -0,0 +1,84 @@
1
+ import { QueryClientProvider, HydrationBoundary } from '@tanstack/react-query';
2
+ import { getTransformer } from '@trpc/client/unstable-internals';
3
+ import { createRootHooks, getQueryClient } from '@trpc/react-query/shared';
4
+ import React, { useState } from 'react';
5
+
6
+ function withTRPC(opts) {
7
+ const { config: getClientConfig } = opts;
8
+ const transformer = getTransformer(opts.transformer);
9
+ return (AppOrPage)=>{
10
+ const trpc = createRootHooks(opts);
11
+ const WithTRPC = (props)=>{
12
+ const [prepassProps] = useState(()=>{
13
+ if (props.trpc) {
14
+ return props.trpc;
15
+ }
16
+ const config = getClientConfig({});
17
+ const queryClient = getQueryClient(config);
18
+ const trpcClient = trpc.createClient(config);
19
+ return {
20
+ abortOnUnmount: config.abortOnUnmount,
21
+ queryClient,
22
+ trpcClient,
23
+ ssrState: opts.ssr ? 'mounting' : false,
24
+ ssrContext: null
25
+ };
26
+ });
27
+ const { queryClient , trpcClient , ssrState , ssrContext } = prepassProps;
28
+ // allow normal components to be wrapped, not just app/pages
29
+ const trpcState = props.pageProps?.trpcState;
30
+ const hydratedState = React.useMemo(()=>{
31
+ if (!trpcState) {
32
+ return trpcState;
33
+ }
34
+ return transformer.input.deserialize(trpcState);
35
+ // eslint-disable-next-line react-hooks/exhaustive-deps
36
+ }, [
37
+ trpcState,
38
+ trpcClient
39
+ ]);
40
+ return /*#__PURE__*/ React.createElement(trpc.Provider, {
41
+ abortOnUnmount: prepassProps.abortOnUnmount ?? false,
42
+ client: trpcClient,
43
+ queryClient: queryClient,
44
+ ssrState: ssrState,
45
+ ssrContext: ssrContext
46
+ }, /*#__PURE__*/ React.createElement(QueryClientProvider, {
47
+ client: queryClient
48
+ }, /*#__PURE__*/ React.createElement(HydrationBoundary, {
49
+ state: hydratedState
50
+ }, /*#__PURE__*/ React.createElement(AppOrPage, Object.assign({}, props)))));
51
+ };
52
+ if (opts.ssr) {
53
+ opts.ssrPrepass({
54
+ parent: opts,
55
+ AppOrPage,
56
+ WithTRPC
57
+ });
58
+ } else if (AppOrPage.getInitialProps) {
59
+ // Allow combining `getServerSideProps` and `getInitialProps`
60
+ WithTRPC.getInitialProps = async (appOrPageCtx)=>{
61
+ // Determine if we are wrapping an App component or a Page component.
62
+ const isApp = !!appOrPageCtx.Component;
63
+ // Run the wrapped component's getInitialProps function.
64
+ let pageProps = {};
65
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
66
+ const originalProps = await AppOrPage.getInitialProps(appOrPageCtx);
67
+ const originalPageProps = isApp ? originalProps.pageProps ?? {} : originalProps;
68
+ pageProps = {
69
+ ...originalPageProps,
70
+ ...pageProps
71
+ };
72
+ const getAppTreeProps = (props)=>isApp ? {
73
+ pageProps: props
74
+ } : props;
75
+ return getAppTreeProps(pageProps);
76
+ };
77
+ }
78
+ const displayName = AppOrPage.displayName ?? AppOrPage.name ?? 'Component';
79
+ WithTRPC.displayName = `withTRPC(${displayName})`;
80
+ return WithTRPC;
81
+ };
82
+ }
83
+
84
+ export { withTRPC };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trpc/next",
3
- "version": "11.0.0-next.91+ca021e61",
3
+ "version": "11.0.0-rc.329+fdcb4a7d8",
4
4
  "description": "The tRPC Next.js library",
5
5
  "author": "KATT",
6
6
  "license": "MIT",
@@ -27,7 +27,7 @@
27
27
  "dev": "pnpm build --watch",
28
28
  "codegen-entrypoints": "tsx entrypoints.script.ts",
29
29
  "ts-watch": "tsc --project tsconfig.watch.json --watch",
30
- "lint": "eslint --cache --ext \".js,.ts,.tsx\" --ignore-path ../../.gitignore --report-unused-disable-directives src"
30
+ "lint": "eslint --cache --ext \".js,.ts,.tsx\" --ignore-path ../../.gitignore src"
31
31
  },
32
32
  "exports": {
33
33
  "./package.json": "./package.json",
@@ -36,11 +36,6 @@
36
36
  "require": "./dist/index.js",
37
37
  "default": "./dist/index.js"
38
38
  },
39
- "./app-dir/server": {
40
- "import": "./dist/app-dir/server.mjs",
41
- "require": "./dist/app-dir/server.js",
42
- "default": "./dist/app-dir/server.js"
43
- },
44
39
  "./app-dir/client": {
45
40
  "import": "./dist/app-dir/client.mjs",
46
41
  "require": "./dist/app-dir/client.js",
@@ -55,6 +50,16 @@
55
50
  "import": "./dist/app-dir/links/nextHttp.mjs",
56
51
  "require": "./dist/app-dir/links/nextHttp.js",
57
52
  "default": "./dist/app-dir/links/nextHttp.js"
53
+ },
54
+ "./app-dir/server": {
55
+ "import": "./dist/app-dir/server.mjs",
56
+ "require": "./dist/app-dir/server.js",
57
+ "default": "./dist/app-dir/server.js"
58
+ },
59
+ "./ssrPrepass": {
60
+ "import": "./dist/ssrPrepass.mjs",
61
+ "require": "./dist/ssrPrepass.js",
62
+ "default": "./dist/ssrPrepass.js"
58
63
  }
59
64
  },
60
65
  "files": [
@@ -63,36 +68,42 @@
63
68
  "README.md",
64
69
  "package.json",
65
70
  "app-dir",
71
+ "ssrPrepass",
66
72
  "!**/*.test.*"
67
73
  ],
68
74
  "peerDependencies": {
69
- "@tanstack/react-query": "^5.0.0",
70
- "@trpc/client": "11.0.0-next.91+ca021e61",
71
- "@trpc/react-query": "11.0.0-next.91+ca021e61",
72
- "@trpc/server": "11.0.0-next.91+ca021e61",
75
+ "@tanstack/react-query": "^5.25.0",
76
+ "@trpc/client": "11.0.0-rc.329+fdcb4a7d8",
77
+ "@trpc/react-query": "11.0.0-rc.329+fdcb4a7d8",
78
+ "@trpc/server": "11.0.0-rc.329+fdcb4a7d8",
73
79
  "next": "*",
74
80
  "react": ">=16.8.0",
75
81
  "react-dom": ">=16.8.0"
76
82
  },
77
- "dependencies": {
78
- "react-ssr-prepass": "^1.5.0"
83
+ "peerDependenciesMeta": {
84
+ "@tanstack/react-query": {
85
+ "optional": true
86
+ },
87
+ "@trpc/react-query": {
88
+ "optional": true
89
+ }
79
90
  },
80
91
  "devDependencies": {
81
- "@tanstack/react-query": "^5.0.0",
82
- "@trpc/client": "11.0.0-next.91+ca021e61",
83
- "@trpc/react-query": "11.0.0-next.91+ca021e61",
84
- "@trpc/server": "11.0.0-next.91+ca021e61",
92
+ "@tanstack/react-query": "^5.25.0",
93
+ "@trpc/client": "11.0.0-rc.329+fdcb4a7d8",
94
+ "@trpc/react-query": "11.0.0-rc.329+fdcb4a7d8",
95
+ "@trpc/server": "11.0.0-rc.329+fdcb4a7d8",
85
96
  "@types/express": "^4.17.17",
86
- "@types/node": "^18.16.16",
87
- "@types/react": "^18.2.8",
88
- "@types/react-dom": "^18.2.4",
89
- "eslint": "^8.40.0",
97
+ "@types/node": "^20.10.0",
98
+ "@types/react": "^18.2.33",
99
+ "@types/react-dom": "^18.2.14",
100
+ "eslint": "^8.56.0",
90
101
  "express": "^4.17.1",
91
- "next": "^13.4.8",
102
+ "next": "^14.1.4",
92
103
  "react": "^18.2.0",
93
104
  "react-dom": "^18.2.0",
94
- "rollup": "^2.79.1",
95
- "tsx": "^3.12.7",
105
+ "rollup": "^4.9.5",
106
+ "tsx": "^4.0.0",
96
107
  "zod": "^3.0.0"
97
108
  },
98
109
  "publishConfig": {
@@ -101,5 +112,5 @@
101
112
  "funding": [
102
113
  "https://trpc.io/sponsor"
103
114
  ],
104
- "gitHead": "ca021e61ba8e6eb6e1715f124489cda75a00b5aa"
115
+ "gitHead": "fdcb4a7d8168d19f9bcbc816b80db815b06a134c"
105
116
  }
@@ -1,11 +1,11 @@
1
+ import type { CreateTRPCClient } from '@trpc/client';
1
2
  import {
2
3
  clientCallTypeToProcedureType,
3
- CreateTRPCClient,
4
4
  createTRPCUntypedClient,
5
5
  } from '@trpc/client';
6
- import { AnyRouter } from '@trpc/server';
7
- import { createRecursiveProxy } from '@trpc/server/shared';
8
- import { CreateTRPCNextAppRouterOptions } from './shared';
6
+ import type { AnyRouter } from '@trpc/server/unstable-core-do-not-import';
7
+ import { createRecursiveProxy } from '@trpc/server/unstable-core-do-not-import';
8
+ import type { CreateTRPCNextAppRouterOptions } from './shared';
9
9
 
10
10
  export {
11
11
  // ts-prune-ignore-next
@@ -1,21 +1,28 @@
1
- import {
1
+ import type {
2
2
  CreateTRPCClientOptions,
3
- createTRPCUntypedClient,
4
- TRPCClientError,
5
3
  TRPCLink,
6
4
  TRPCRequestOptions,
7
5
  } from '@trpc/client';
8
- import { transformResult } from '@trpc/client/shared';
9
- import {
10
- AnyRouter,
6
+ import { createTRPCUntypedClient, TRPCClientError } from '@trpc/client';
7
+ import type {
8
+ CoercedTransformerParameters,
9
+ TransformerOptions,
10
+ } from '@trpc/client/unstable-internals';
11
+ import { getTransformer } from '@trpc/client/unstable-internals';
12
+ import { observable } from '@trpc/server/observable';
13
+ import type {
14
+ inferClientTypes,
15
+ InferrableClientTypes,
11
16
  MaybePromise,
12
17
  ProcedureOptions,
13
18
  Simplify,
14
- } from '@trpc/server';
15
- import { observable } from '@trpc/server/observable';
19
+ TypeError,
20
+ } from '@trpc/server/unstable-core-do-not-import';
21
+ import { transformResult } from '@trpc/server/unstable-core-do-not-import';
16
22
  import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
17
- import { TRPCActionHandler } from './server';
18
- import { ActionHandlerDef, isFormData } from './shared';
23
+ import type { TRPCActionHandler } from './server';
24
+ import type { ActionHandlerDef } from './shared';
25
+ import { isFormData } from './shared';
19
26
 
20
27
  type MutationArgs<TDef extends ActionHandlerDef> = TDef['input'] extends void
21
28
  ? [input?: undefined | void, opts?: ProcedureOptions]
@@ -67,9 +74,27 @@ type ActionContext = {
67
74
 
68
75
  // ts-prune-ignore-next
69
76
  export function experimental_serverActionLink<
70
- TRouter extends AnyRouter = AnyRouter,
71
- >(): TRPCLink<TRouter> {
72
- return (runtime) =>
77
+ TInferrable extends InferrableClientTypes,
78
+ >(
79
+ ...args: InferrableClientTypes extends TInferrable
80
+ ? [
81
+ TypeError<'Generic parameter missing in `experimental_createActionHook<HERE>()` or experimental_serverActionLink<HERE>()'>,
82
+ ]
83
+ : inferClientTypes<TInferrable>['transformer'] extends true
84
+ ? [
85
+ opts: TransformerOptions<{
86
+ transformer: true;
87
+ }>,
88
+ ]
89
+ : [
90
+ opts?: TransformerOptions<{
91
+ transformer: false;
92
+ }>,
93
+ ]
94
+ ): TRPCLink<TInferrable> {
95
+ const [opts] = args as [CoercedTransformerParameters];
96
+ const transformer = getTransformer(opts?.transformer);
97
+ return () =>
73
98
  ({ op }) =>
74
99
  observable((observer) => {
75
100
  const context = op.context as ActionContext;
@@ -78,10 +103,10 @@ export function experimental_serverActionLink<
78
103
  ._action(
79
104
  isFormData(op.input)
80
105
  ? op.input
81
- : runtime.transformer.serialize(op.input),
106
+ : transformer.input.serialize(op.input),
82
107
  )
83
108
  .then((data) => {
84
- const transformed = transformResult(data, runtime);
109
+ const transformed = transformResult(data, transformer.output);
85
110
 
86
111
  if (!transformed.ok) {
87
112
  observer.error(TRPCClientError.from(transformed.error, {}));
@@ -103,15 +128,20 @@ interface UseTRPCActionOptions<TDef extends ActionHandlerDef> {
103
128
  onSuccess?: (result: TDef['output']) => MaybePromise<void> | void;
104
129
  onError?: (result: TRPCClientError<TDef['errorShape']>) => MaybePromise<void>;
105
130
  }
106
-
107
131
  // ts-prune-ignore-next
108
- export function experimental_createActionHook<TRouter extends AnyRouter>(
109
- opts: CreateTRPCClientOptions<TRouter>,
132
+ export function experimental_createActionHook<
133
+ TInferrable extends InferrableClientTypes,
134
+ >(
135
+ opts: InferrableClientTypes extends TInferrable
136
+ ? TypeError<'Generic parameter missing in `experimental_createActionHook<HERE>()`'>
137
+ : CreateTRPCClientOptions<TInferrable>,
110
138
  ) {
111
139
  type ActionContext = {
112
140
  _action: (...args: any[]) => Promise<any>;
113
141
  };
114
- const client = createTRPCUntypedClient(opts);
142
+ const client = createTRPCUntypedClient(
143
+ opts as Exclude<typeof opts, TypeError<any>>,
144
+ );
115
145
  return function useAction<TDef extends ActionHandlerDef>(
116
146
  handler: TRPCActionHandler<TDef>,
117
147
  useActionOpts?: UseTRPCActionOptions<Simplify<TDef>>,
@@ -1,8 +1,18 @@
1
1
  // import "server-only";
2
2
 
3
- import { TRPCClientError, TRPCLink } from '@trpc/client';
4
- import { AnyRouter, callProcedure, inferRouterContext } from '@trpc/server';
3
+ import type { TRPCLink } from '@trpc/client';
4
+ import { TRPCClientError } from '@trpc/client';
5
+ import {
6
+ getTransformer,
7
+ type TransformerOptions,
8
+ } from '@trpc/client/unstable-internals';
5
9
  import { observable } from '@trpc/server/observable';
10
+ import type {
11
+ AnyRouter,
12
+ inferClientTypes,
13
+ inferRouterContext,
14
+ } from '@trpc/server/unstable-core-do-not-import';
15
+ import { callProcedure } from '@trpc/server/unstable-core-do-not-import';
6
16
  import { unstable_cache } from 'next/cache';
7
17
  import { generateCacheTag } from '../shared';
8
18
 
@@ -11,13 +21,14 @@ type NextCacheLinkOptions<TRouter extends AnyRouter> = {
11
21
  createContext: () => Promise<inferRouterContext<TRouter>>;
12
22
  /** how many seconds the cache should hold before revalidating */
13
23
  revalidate?: number | false;
14
- };
24
+ } & TransformerOptions<inferClientTypes<TRouter>>;
15
25
 
16
26
  // ts-prune-ignore-next
17
27
  export function experimental_nextCacheLink<TRouter extends AnyRouter>(
18
28
  opts: NextCacheLinkOptions<TRouter>,
19
29
  ): TRPCLink<TRouter> {
20
- return (runtime) =>
30
+ const transformer = getTransformer(opts.transformer);
31
+ return () =>
21
32
  ({ op }) =>
22
33
  observable((observer) => {
23
34
  const { path, input, type, context } = op;
@@ -25,8 +36,9 @@ export function experimental_nextCacheLink<TRouter extends AnyRouter>(
25
36
  const cacheTag = generateCacheTag(path, input);
26
37
  // Let per-request revalidate override global revalidate
27
38
  const requestRevalidate =
28
- typeof context.revalidate === 'number' || context.revalidate === false
29
- ? context.revalidate
39
+ typeof context['revalidate'] === 'number' ||
40
+ context['revalidate'] === false
41
+ ? context['revalidate']
30
42
  : undefined;
31
43
  const revalidate = requestRevalidate ?? opts.revalidate ?? false;
32
44
 
@@ -46,7 +58,7 @@ export function experimental_nextCacheLink<TRouter extends AnyRouter>(
46
58
  });
47
59
 
48
60
  // We need to serialize cause the cache only accepts JSON
49
- return runtime.transformer.serialize(procedureResult);
61
+ return transformer.input.serialize(procedureResult);
50
62
  };
51
63
 
52
64
  if (type === 'query') {
@@ -64,7 +76,7 @@ export function experimental_nextCacheLink<TRouter extends AnyRouter>(
64
76
 
65
77
  promise
66
78
  .then((data) => {
67
- const transformedResult = runtime.transformer.deserialize(data);
79
+ const transformedResult = transformer.output.deserialize(data);
68
80
  observer.next({ result: { data: transformedResult } });
69
81
  observer.complete();
70
82
  })
@@ -1,25 +1,36 @@
1
- import {
2
- httpBatchLink,
1
+ import type {
3
2
  HTTPBatchLinkOptions,
4
- httpLink,
5
3
  HTTPLinkOptions,
6
4
  TRPCLink,
7
5
  } from '@trpc/client';
8
- import { AnyRouter } from '@trpc/server';
6
+ import { httpBatchLink, httpLink } from '@trpc/client';
7
+ import type {
8
+ AnyRootTypes,
9
+ AnyRouter,
10
+ } from '@trpc/server/unstable-core-do-not-import';
9
11
  import { generateCacheTag } from '../shared';
10
12
 
11
- type NextFetchLinkOptions<TBatch extends boolean> = (TBatch extends true
12
- ? HTTPBatchLinkOptions
13
- : HTTPLinkOptions) & {
14
- batch?: TBatch;
13
+ interface NextLinkBaseOptions {
15
14
  revalidate?: number | false;
16
- };
15
+ batch?: boolean;
16
+ }
17
+
18
+ type NextLinkSingleOptions<TRoot extends AnyRootTypes> = NextLinkBaseOptions &
19
+ Omit<HTTPLinkOptions<TRoot>, 'fetch'> & {
20
+ batch?: false;
21
+ };
22
+
23
+ type NextLinkBatchOptions<TRoot extends AnyRootTypes> = NextLinkBaseOptions &
24
+ Omit<HTTPBatchLinkOptions<TRoot>, 'fetch'> & {
25
+ batch: true;
26
+ };
17
27
 
18
28
  // ts-prune-ignore-next
19
- export function experimental_nextHttpLink<
20
- TRouter extends AnyRouter,
21
- TBatch extends boolean,
22
- >(opts: NextFetchLinkOptions<TBatch>): TRPCLink<TRouter> {
29
+ export function experimental_nextHttpLink<TRouter extends AnyRouter>(
30
+ opts:
31
+ | NextLinkSingleOptions<TRouter['_def']['_config']['$types']>
32
+ | NextLinkBatchOptions<TRouter['_def']['_config']['$types']>,
33
+ ): TRPCLink<TRouter> {
23
34
  return (runtime) => {
24
35
  return (ctx) => {
25
36
  const { path, input, context } = ctx.op;
@@ -27,28 +38,37 @@ export function experimental_nextHttpLink<
27
38
 
28
39
  // Let per-request revalidate override global revalidate
29
40
  const requestRevalidate =
30
- typeof context.revalidate === 'number' || context.revalidate === false
31
- ? context.revalidate
41
+ typeof context['revalidate'] === 'number' ||
42
+ context['revalidate'] === false
43
+ ? context['revalidate']
32
44
  : undefined;
45
+
33
46
  const revalidate = requestRevalidate ?? opts.revalidate ?? false;
34
47
 
35
- const linkFactory = opts.batch ? httpBatchLink : httpLink;
36
- const link = linkFactory({
37
- headers: opts.headers as any,
38
- url: opts.url,
39
- fetch: (url, fetchOpts) => {
40
- return fetch(url, {
41
- ...fetchOpts,
42
- // cache: 'no-cache',
43
- next: {
44
- revalidate,
45
- tags: [cacheTag],
46
- },
48
+ const _fetch: NonNullable<HTTPLinkOptions<AnyRootTypes>['fetch']> = (
49
+ url,
50
+ fetchOpts,
51
+ ) => {
52
+ return fetch(url, {
53
+ ...fetchOpts,
54
+ // cache: 'no-cache',
55
+ next: {
56
+ revalidate,
57
+ tags: [cacheTag],
58
+ },
59
+ });
60
+ };
61
+ const link = opts.batch
62
+ ? httpBatchLink({
63
+ ...(opts as any),
64
+ fetch: _fetch,
65
+ })
66
+ : httpLink({
67
+ ...(opts as any),
68
+ fetch: _fetch,
47
69
  });
48
- },
49
- })(runtime);
50
70
 
51
- return link(ctx);
71
+ return link(runtime)(ctx);
52
72
  };
53
73
  };
54
74
  }