graphql-codegen-plugin-typescript-swr 0.8.5 → 0.9.0

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 (115) hide show
  1. package/README.md +5 -0
  2. package/build/main/visitor.js +2 -2
  3. package/build/module/visitor.js +2 -2
  4. package/package.json +8 -5
  5. package/.editorconfig +0 -13
  6. package/.eslintrc.js +0 -63
  7. package/.github/CONTRIBUTING.md +0 -3
  8. package/.github/ISSUE_TEMPLATE.md +0 -9
  9. package/.github/PULL_REQUEST_TEMPLATE.md +0 -7
  10. package/.github/workflows/main.yml +0 -28
  11. package/.gitignore +0 -8
  12. package/.prettierignore +0 -3
  13. package/.prettierrc.json +0 -4
  14. package/.vscode/extensions.json +0 -8
  15. package/.vscode/launch.json +0 -29
  16. package/.vscode/settings.json +0 -41
  17. package/build/tsconfig.main.tsbuildinfo +0 -1
  18. package/build/tsconfig.module.tsbuildinfo +0 -1
  19. package/dev-test/.env +0 -1
  20. package/dev-test/codegen.yml +0 -357
  21. package/dev-test/githunt/__generated__/comment-added.subscription.stencil-component.tsx +0 -47
  22. package/dev-test/githunt/__generated__/comment.query.stencil-component.tsx +0 -68
  23. package/dev-test/githunt/__generated__/comments-page-comment.fragment.stencil-component.tsx +0 -20
  24. package/dev-test/githunt/__generated__/current-user.query.stencil-component.tsx +0 -34
  25. package/dev-test/githunt/__generated__/feed-entry.fragment.stencil-component.tsx +0 -30
  26. package/dev-test/githunt/__generated__/feed.query.stencil-component.tsx +0 -40
  27. package/dev-test/githunt/__generated__/new-entry.mutation.stencil-component.tsx +0 -35
  28. package/dev-test/githunt/__generated__/repo-info.fragment.stencil-component.tsx +0 -26
  29. package/dev-test/githunt/__generated__/submit-comment.mutation.stencil-component.tsx +0 -35
  30. package/dev-test/githunt/__generated__/vote-buttons.fragment.stencil-component.tsx +0 -16
  31. package/dev-test/githunt/__generated__/vote.mutation.stencil-component.tsx +0 -41
  32. package/dev-test/githunt/comment-added.subscription.graphql +0 -11
  33. package/dev-test/githunt/comment.query.graphql +0 -33
  34. package/dev-test/githunt/comments-page-comment.fragment.graphql +0 -9
  35. package/dev-test/githunt/current-user.query.graphql +0 -6
  36. package/dev-test/githunt/feed-entry.fragment.graphql +0 -13
  37. package/dev-test/githunt/feed.query.graphql +0 -8
  38. package/dev-test/githunt/flow.flow.js +0 -367
  39. package/dev-test/githunt/graphql-declared-modules.d.ts +0 -87
  40. package/dev-test/githunt/new-entry.mutation.graphql +0 -5
  41. package/dev-test/githunt/repo-info.fragment.graphql +0 -12
  42. package/dev-test/githunt/schema.js +0 -3
  43. package/dev-test/githunt/schema.json +0 -1750
  44. package/dev-test/githunt/submit-comment.mutation.graphql +0 -5
  45. package/dev-test/githunt/typed-document-nodes.ts +0 -892
  46. package/dev-test/githunt/types.apolloAngular.sdk.ts +0 -570
  47. package/dev-test/githunt/types.apolloAngular.ts +0 -491
  48. package/dev-test/githunt/types.avoidOptionals.ts +0 -266
  49. package/dev-test/githunt/types.d.ts +0 -261
  50. package/dev-test/githunt/types.enumsAsTypes.ts +0 -261
  51. package/dev-test/githunt/types.flatten.preResolveTypes.ts +0 -289
  52. package/dev-test/githunt/types.immutableTypes.ts +0 -267
  53. package/dev-test/githunt/types.preResolveTypes.compatibility.ts +0 -368
  54. package/dev-test/githunt/types.preResolveTypes.onlyOperationTypes.ts +0 -156
  55. package/dev-test/githunt/types.preResolveTypes.ts +0 -293
  56. package/dev-test/githunt/types.reactApollo.customSuffix.tsx +0 -634
  57. package/dev-test/githunt/types.reactApollo.hooks.tsx +0 -621
  58. package/dev-test/githunt/types.reactApollo.preResolveTypes.tsx +0 -648
  59. package/dev-test/githunt/types.reactApollo.tsx +0 -621
  60. package/dev-test/githunt/types.reactApollo.v2.tsx +0 -635
  61. package/dev-test/githunt/types.stencilApollo.tsx +0 -484
  62. package/dev-test/githunt/types.ts +0 -266
  63. package/dev-test/githunt/types.urql.tsx +0 -444
  64. package/dev-test/githunt/types.vueApollo.ts +0 -647
  65. package/dev-test/githunt/vote-buttons.fragment.graphql +0 -6
  66. package/dev-test/githunt/vote.mutation.graphql +0 -9
  67. package/dev-test/setup.js +0 -3
  68. package/dev-test/test-message/documents.ts +0 -46
  69. package/dev-test/test-message/schema.graphql +0 -23
  70. package/dev-test/test-message/types.tsx +0 -237
  71. package/dev-test/test-schema/env.types.ts +0 -35
  72. package/dev-test/test-schema/flow-types.flow.js +0 -139
  73. package/dev-test/test-schema/local/schema-ast.js +0 -2
  74. package/dev-test/test-schema/local/schema-formats.js +0 -20
  75. package/dev-test/test-schema/local/schema-object.js +0 -2
  76. package/dev-test/test-schema/local/schema-text.js +0 -2
  77. package/dev-test/test-schema/local/schema.graphql +0 -8
  78. package/dev-test/test-schema/resolvers-federation.ts +0 -233
  79. package/dev-test/test-schema/resolvers-root.ts +0 -178
  80. package/dev-test/test-schema/resolvers-types.ts +0 -168
  81. package/dev-test/test-schema/schema-ast.js +0 -2
  82. package/dev-test/test-schema/schema-federation.graphql +0 -30
  83. package/dev-test/test-schema/schema-formats.js +0 -38
  84. package/dev-test/test-schema/schema-json.js +0 -2
  85. package/dev-test/test-schema/schema-object.js +0 -2
  86. package/dev-test/test-schema/schema-text.js +0 -2
  87. package/dev-test/test-schema/schema-with-imports.graphql +0 -9
  88. package/dev-test/test-schema/schema-with-root.graphql +0 -22
  89. package/dev-test/test-schema/schema.graphql +0 -19
  90. package/dev-test/test-schema/schema.json +0 -1070
  91. package/dev-test/test-schema/types.preResolveTypes.onlyOperationTypes.ts +0 -19
  92. package/dev-test/test-schema/types.preResolveTypes.ts +0 -44
  93. package/dev-test/test-schema/typings.avoidOptionals.ts +0 -27
  94. package/dev-test/test-schema/typings.enum.ts +0 -19
  95. package/dev-test/test-schema/typings.immutableTypes.ts +0 -27
  96. package/dev-test/test-schema/typings.ts +0 -156
  97. package/dev-test/test-schema/typings.wrapped.ts +0 -29
  98. package/dev-test/tsconfig.json +0 -18
  99. package/jest.config.js +0 -30
  100. package/renovate.json +0 -2
  101. package/src/config.ts +0 -29
  102. package/src/index.ts +0 -54
  103. package/src/visitor.ts +0 -259
  104. package/tests/outputs/autogenSWRKey.ts +0 -46
  105. package/tests/outputs/excludeQueries.ts +0 -13
  106. package/tests/outputs/infinite.ts +0 -49
  107. package/tests/outputs/mutations.ts +0 -19
  108. package/tests/outputs/rawRequest.ts +0 -19
  109. package/tests/outputs/straight.ts +0 -19
  110. package/tests/swr.spec.ts +0 -306
  111. package/tests/visitor.spec.ts +0 -19
  112. package/tsconfig.json +0 -32
  113. package/tsconfig.main.json +0 -11
  114. package/tsconfig.module.json +0 -13
  115. package/yarn.lock +0 -5359
package/src/visitor.ts DELETED
@@ -1,259 +0,0 @@
1
- import {
2
- ClientSideBasePluginConfig,
3
- ClientSideBaseVisitor,
4
- indentMultiline,
5
- LoadedFragment,
6
- ParsedConfig,
7
- } from '@graphql-codegen/visitor-plugin-common'
8
- import { GraphQLSchema, Kind, OperationDefinitionNode } from 'graphql'
9
- import glob from 'micromatch'
10
- import { pascalCase } from 'pascal-case'
11
-
12
- import { RawSWRPluginConfig } from './config'
13
-
14
- export interface SWRPluginConfig extends ClientSideBasePluginConfig {
15
- rawRequest: boolean
16
- excludeQueries: string | string[]
17
- useSWRInfinite: string | string[]
18
- autogenSWRKey: boolean
19
- }
20
-
21
- export interface Operation {
22
- node: OperationDefinitionNode
23
- documentVariableName: string
24
- operationType: string
25
- operationResultType: string
26
- operationVariablesTypes: string
27
- }
28
-
29
- export interface ComposeQueryHandlerConfig {
30
- autogenKey: SWRPluginConfig['autogenSWRKey']
31
- infinite: boolean
32
- rawRequest: SWRPluginConfig['rawRequest']
33
- typesPrefix: ParsedConfig['typesPrefix']
34
- typesSuffix: ParsedConfig['typesSuffix']
35
- }
36
-
37
- const composeQueryHandler = (
38
- operation: Operation,
39
- config: ComposeQueryHandlerConfig
40
- ): string[] => {
41
- const codes: string[] = []
42
- const { node } = operation
43
- const optionalVariables =
44
- !node.variableDefinitions ||
45
- node.variableDefinitions.length === 0 ||
46
- node.variableDefinitions.every(
47
- (v) => v.type.kind !== Kind.NON_NULL_TYPE || v.defaultValue
48
- )
49
- ? '?'
50
- : ''
51
- const name = node.name.value
52
- const pascalName = pascalCase(node.name.value)
53
- const responseType = config.rawRequest
54
- ? `SWRRawResponse<${operation.operationResultType}>`
55
- : operation.operationResultType
56
- const variablesType = operation.operationVariablesTypes
57
-
58
- codes.push(`use${pascalName}(${
59
- config.autogenKey ? '' : 'key: SWRKeyInterface, '
60
- }variables${optionalVariables}: ${variablesType}, config?: SWRConfigInterface<${responseType}, ClientError>) {
61
- return useSWR<${responseType}, ClientError>(${
62
- config.autogenKey
63
- ? `genKey<${variablesType}>('${pascalName}', variables)`
64
- : 'key'
65
- }, () => sdk.${name}(variables), config);
66
- }`)
67
-
68
- if (config.infinite) {
69
- codes.push(`use${pascalName}Infinite(${
70
- config.autogenKey ? '' : 'id: string, '
71
- }getKey: ${config.typesPrefix}SWRInfiniteKeyLoader${
72
- config.typesSuffix
73
- }<${responseType}, ${variablesType}>, variables${optionalVariables}: ${variablesType}, config?: SWRInfiniteConfiguration<${responseType}, ClientError>) {
74
- return useSWRInfinite<${responseType}, ClientError>(
75
- utilsForInfinite.generateGetKey<${responseType}, ${variablesType}>(${
76
- config.autogenKey
77
- ? `genKey<${variablesType}>('${pascalName}', variables)`
78
- : 'id'
79
- }, getKey),
80
- utilsForInfinite.generateFetcher<${responseType}, ${variablesType}>(sdk.${name}, variables),
81
- config);
82
- }`)
83
- }
84
-
85
- return codes
86
- }
87
-
88
- export class SWRVisitor extends ClientSideBaseVisitor<
89
- RawSWRPluginConfig,
90
- SWRPluginConfig
91
- > {
92
- private _operationsToInclude: Operation[] = []
93
-
94
- private _enabledInfinite = false
95
-
96
- constructor(
97
- schema: GraphQLSchema,
98
- fragments: LoadedFragment[],
99
- rawConfig: RawSWRPluginConfig
100
- ) {
101
- super(schema, fragments, rawConfig, {
102
- excludeQueries: rawConfig.excludeQueries || null,
103
- useSWRInfinite: rawConfig.useSWRInfinite || null,
104
- autogenSWRKey: rawConfig.autogenSWRKey || false,
105
- })
106
-
107
- this._enabledInfinite =
108
- (this.config.useSWRInfinite &&
109
- typeof this.config.useSWRInfinite === 'string') ||
110
- (Array.isArray(this.config.useSWRInfinite) &&
111
- this.config.useSWRInfinite.length > 0)
112
-
113
- const typeImport = this.config.useTypeImports ? 'import type' : 'import'
114
-
115
- this._additionalImports.push(
116
- `${typeImport} { ClientError } from 'graphql-request/dist/types';`
117
- )
118
-
119
- if (this.config.useTypeImports) {
120
- if (this._enabledInfinite) {
121
- this._additionalImports.push(
122
- `import type { SWRConfiguration as SWRConfigInterface, Key as SWRKeyInterface } from 'swr';`
123
- )
124
- this._additionalImports.push(
125
- `import type { SWRInfiniteConfiguration } from 'swr/infinite';`
126
- )
127
- this._additionalImports.push(`import useSWR from 'swr';`)
128
- this._additionalImports.push(
129
- `import useSWRInfinite from 'swr/infinite';`
130
- )
131
- } else {
132
- this._additionalImports.push(
133
- `import type { SWRConfiguration as SWRConfigInterface, Key as SWRKeyInterface } from 'swr';`
134
- )
135
- this._additionalImports.push(`import useSWR from 'swr';`)
136
- }
137
- } else if (this._enabledInfinite) {
138
- this._additionalImports.push(
139
- `import useSWR, { SWRConfiguration as SWRConfigInterface, Key as SWRKeyInterface } from 'swr';`
140
- )
141
- this._additionalImports.push(
142
- `import useSWRInfinite, { SWRInfiniteConfiguration } from 'swr/infinite';`
143
- )
144
- } else {
145
- this._additionalImports.push(
146
- `import useSWR, { SWRConfiguration as SWRConfigInterface, Key as SWRKeyInterface } from 'swr';`
147
- )
148
- }
149
- }
150
-
151
- protected buildOperation(
152
- node: OperationDefinitionNode,
153
- documentVariableName: string,
154
- operationType: string,
155
- operationResultType: string,
156
- operationVariablesTypes: string
157
- ): string {
158
- this._operationsToInclude.push({
159
- node,
160
- documentVariableName,
161
- operationType,
162
- operationResultType,
163
- operationVariablesTypes,
164
- })
165
-
166
- return null
167
- }
168
-
169
- public get sdkContent(): string {
170
- const codes: string[] = []
171
- const { config } = this
172
- const disabledexcludeQueries =
173
- !config.excludeQueries ||
174
- (Array.isArray(config.excludeQueries) && !config.excludeQueries.length)
175
- const allPossibleActions = this._operationsToInclude
176
- .filter((o) => {
177
- if (o.operationType !== 'Query') {
178
- return false
179
- }
180
- if (disabledexcludeQueries) {
181
- return true
182
- }
183
- return !glob.isMatch(o.node.name.value, config.excludeQueries)
184
- })
185
- .map((o) =>
186
- composeQueryHandler(o, {
187
- autogenKey: config.autogenSWRKey,
188
- infinite:
189
- this._enabledInfinite &&
190
- glob.isMatch(o.node.name.value, config.useSWRInfinite),
191
- rawRequest: config.rawRequest,
192
- typesPrefix: config.typesPrefix,
193
- typesSuffix: config.typesSuffix,
194
- })
195
- )
196
- .reduce((p, c) => p.concat(c), [])
197
- .map((s) => indentMultiline(s, 2))
198
-
199
- // Add type of SWRRawResponse
200
- if (config.rawRequest) {
201
- codes.push(
202
- `type SWRRawResponse<Data = any> = { data?: Data | undefined; extensions?: any; headers: Headers; status: number; errors?: GraphQLError[] | undefined; };`
203
- )
204
- }
205
-
206
- // Add type of SWRInfiniteKeyLoader
207
- if (this._enabledInfinite) {
208
- codes.push(`export type ${config.typesPrefix}SWRInfiniteKeyLoader${config.typesSuffix}<Data = unknown, Variables = unknown> = (
209
- index: number,
210
- previousPageData: Data | null
211
- ) => [keyof Variables, Variables[keyof Variables] | null] | null;`)
212
- }
213
-
214
- // Add getSdkWithHooks function
215
- codes.push(`export function getSdkWithHooks(client: GraphQLClient, withWrapper: SdkFunctionWrapper = defaultWrapper) {
216
- const sdk = getSdk(client, withWrapper);`)
217
-
218
- // Add the utility for useSWRInfinite
219
- if (this._enabledInfinite) {
220
- codes.push(` const utilsForInfinite = {
221
- generateGetKey: <Data = unknown, Variables = unknown>(
222
- id: ${config.autogenSWRKey ? 'SWRKeyInterface' : 'string'},
223
- getKey: ${config.typesPrefix}SWRInfiniteKeyLoader${
224
- config.typesSuffix
225
- }<Data, Variables>
226
- ) => (pageIndex: number, previousData: Data | null) => {
227
- const key = getKey(pageIndex, previousData)
228
- return key ? [id, ...key] : null
229
- },
230
- generateFetcher: <Query = unknown, Variables = unknown>(query: (variables: Variables) => Promise<Query>, variables?: Variables) => (
231
- id: string,
232
- fieldName: keyof Variables,
233
- fieldValue: Variables[typeof fieldName]
234
- ) => query({ ...variables, [fieldName]: fieldValue } as Variables)
235
- }`)
236
- }
237
-
238
- // Add the function for auto-generation key for SWR
239
- if (config.autogenSWRKey) {
240
- codes.push(
241
- ` const genKey = <V extends Record<string, unknown> = Record<string, unknown>>(name: string, object: V = {} as V): SWRKeyInterface => [name, ...Object.keys(object).sort().map(key => object[key])];`
242
- )
243
- }
244
-
245
- // Add return statement for getSdkWithHooks function and close the function
246
- codes.push(` return {
247
- ...sdk,
248
- ${allPossibleActions.join(',\n')}
249
- };
250
- }`)
251
-
252
- // Add type of Sdk
253
- codes.push(
254
- `export type ${config.typesPrefix}SdkWithHooks${config.typesSuffix} = ReturnType<typeof getSdkWithHooks>;`
255
- )
256
-
257
- return codes.join('\n')
258
- }
259
- }
@@ -1,46 +0,0 @@
1
- export function getSdkWithHooks(client: GraphQLClient, withWrapper: SdkFunctionWrapper = defaultWrapper) {
2
- const sdk = getSdk(client, withWrapper);
3
- const utilsForInfinite = {
4
- generateGetKey: <Data = unknown, Variables = unknown>(
5
- id: SWRKeyInterface,
6
- getKey: SWRInfiniteKeyLoader<Data, Variables>
7
- ) => (pageIndex: number, previousData: Data | null) => {
8
- const key = getKey(pageIndex, previousData)
9
- return key ? [id, ...key] : null
10
- },
11
- generateFetcher: <Query = unknown, Variables = unknown>(query: (variables: Variables) => Promise<Query>, variables?: Variables) => (
12
- id: string,
13
- fieldName: keyof Variables,
14
- fieldValue: Variables[typeof fieldName]
15
- ) => query({ ...variables, [fieldName]: fieldValue } as Variables)
16
- }
17
- const genKey = <V extends Record<string, unknown> = Record<string, unknown>>(name: string, object: V = {} as V): SWRKeyInterface => [name, ...Object.keys(object).sort().map(key => object[key])];
18
- return {
19
- ...sdk,
20
- useFeed(variables?: FeedQueryVariables, config?: SWRConfigInterface<FeedQuery, ClientError>) {
21
- return useSWR<FeedQuery, ClientError>(genKey<FeedQueryVariables>('Feed', variables), () => sdk.feed(variables), config);
22
- },
23
- useFeed2(variables: Feed2QueryVariables, config?: SWRConfigInterface<Feed2Query, ClientError>) {
24
- return useSWR<Feed2Query, ClientError>(genKey<Feed2QueryVariables>('Feed2', variables), () => sdk.feed2(variables), config);
25
- },
26
- useFeed2Infinite(getKey: SWRInfiniteKeyLoader<Feed2Query, Feed2QueryVariables>, variables: Feed2QueryVariables, config?: SWRInfiniteConfiguration<Feed2Query, ClientError>) {
27
- return useSWRInfinite<Feed2Query, ClientError>(
28
- utilsForInfinite.generateGetKey<Feed2Query, Feed2QueryVariables>(genKey<Feed2QueryVariables>('Feed2', variables), getKey),
29
- utilsForInfinite.generateFetcher<Feed2Query, Feed2QueryVariables>(sdk.feed2, variables),
30
- config);
31
- },
32
- useFeed3(variables?: Feed3QueryVariables, config?: SWRConfigInterface<Feed3Query, ClientError>) {
33
- return useSWR<Feed3Query, ClientError>(genKey<Feed3QueryVariables>('Feed3', variables), () => sdk.feed3(variables), config);
34
- },
35
- useFeed4(variables?: Feed4QueryVariables, config?: SWRConfigInterface<Feed4Query, ClientError>) {
36
- return useSWR<Feed4Query, ClientError>(genKey<Feed4QueryVariables>('Feed4', variables), () => sdk.feed4(variables), config);
37
- },
38
- useFeed4Infinite(getKey: SWRInfiniteKeyLoader<Feed4Query, Feed4QueryVariables>, variables?: Feed4QueryVariables, config?: SWRInfiniteConfiguration<Feed4Query, ClientError>) {
39
- return useSWRInfinite<Feed4Query, ClientError>(
40
- utilsForInfinite.generateGetKey<Feed4Query, Feed4QueryVariables>(genKey<Feed4QueryVariables>('Feed4', variables), getKey),
41
- utilsForInfinite.generateFetcher<Feed4Query, Feed4QueryVariables>(sdk.feed4, variables),
42
- config);
43
- }
44
- };
45
- }
46
- export type SdkWithHooks = ReturnType<typeof getSdkWithHooks>;
@@ -1,13 +0,0 @@
1
- export function getSdkWithHooks(client: GraphQLClient, withWrapper: SdkFunctionWrapper = defaultWrapper) {
2
- const sdk = getSdk(client, withWrapper);
3
- return {
4
- ...sdk,
5
- useFeed(key: SWRKeyInterface, variables?: FeedQueryVariables, config?: SWRConfigInterface<FeedQuery, ClientError>) {
6
- return useSWR<FeedQuery, ClientError>(key, () => sdk.feed(variables), config);
7
- },
8
- useFeed4(key: SWRKeyInterface, variables?: Feed4QueryVariables, config?: SWRConfigInterface<Feed4Query, ClientError>) {
9
- return useSWR<Feed4Query, ClientError>(key, () => sdk.feed4(variables), config);
10
- }
11
- };
12
- }
13
- export type SdkWithHooks = ReturnType<typeof getSdkWithHooks>;
@@ -1,49 +0,0 @@
1
- export type SWRInfiniteKeyLoader<Data = unknown, Variables = unknown> = (
2
- index: number,
3
- previousPageData: Data | null
4
- ) => [keyof Variables, Variables[keyof Variables] | null] | null;
5
- export function getSdkWithHooks(client: GraphQLClient, withWrapper: SdkFunctionWrapper = defaultWrapper) {
6
- const sdk = getSdk(client, withWrapper);
7
- const utilsForInfinite = {
8
- generateGetKey: <Data = unknown, Variables = unknown>(
9
- id: string,
10
- getKey: SWRInfiniteKeyLoader<Data, Variables>
11
- ) => (pageIndex: number, previousData: Data | null) => {
12
- const key = getKey(pageIndex, previousData)
13
- return key ? [id, ...key] : null
14
- },
15
- generateFetcher: <Query = unknown, Variables = unknown>(query: (variables: Variables) => Promise<Query>, variables?: Variables) => (
16
- id: string,
17
- fieldName: keyof Variables,
18
- fieldValue: Variables[typeof fieldName]
19
- ) => query({ ...variables, [fieldName]: fieldValue } as Variables)
20
- }
21
- return {
22
- ...sdk,
23
- useFeed(key: SWRKeyInterface, variables?: FeedQueryVariables, config?: SWRConfigInterface<FeedQuery, ClientError>) {
24
- return useSWR<FeedQuery, ClientError>(key, () => sdk.feed(variables), config);
25
- },
26
- useFeed2(key: SWRKeyInterface, variables: Feed2QueryVariables, config?: SWRConfigInterface<Feed2Query, ClientError>) {
27
- return useSWR<Feed2Query, ClientError>(key, () => sdk.feed2(variables), config);
28
- },
29
- useFeed2Infinite(id: string, getKey: SWRInfiniteKeyLoader<Feed2Query, Feed2QueryVariables>, variables: Feed2QueryVariables, config?: SWRInfiniteConfiguration<Feed2Query, ClientError>) {
30
- return useSWRInfinite<Feed2Query, ClientError>(
31
- utilsForInfinite.generateGetKey<Feed2Query, Feed2QueryVariables>(id, getKey),
32
- utilsForInfinite.generateFetcher<Feed2Query, Feed2QueryVariables>(sdk.feed2, variables),
33
- config);
34
- },
35
- useFeed3(key: SWRKeyInterface, variables?: Feed3QueryVariables, config?: SWRConfigInterface<Feed3Query, ClientError>) {
36
- return useSWR<Feed3Query, ClientError>(key, () => sdk.feed3(variables), config);
37
- },
38
- useFeed4(key: SWRKeyInterface, variables?: Feed4QueryVariables, config?: SWRConfigInterface<Feed4Query, ClientError>) {
39
- return useSWR<Feed4Query, ClientError>(key, () => sdk.feed4(variables), config);
40
- },
41
- useFeed4Infinite(id: string, getKey: SWRInfiniteKeyLoader<Feed4Query, Feed4QueryVariables>, variables?: Feed4QueryVariables, config?: SWRInfiniteConfiguration<Feed4Query, ClientError>) {
42
- return useSWRInfinite<Feed4Query, ClientError>(
43
- utilsForInfinite.generateGetKey<Feed4Query, Feed4QueryVariables>(id, getKey),
44
- utilsForInfinite.generateFetcher<Feed4Query, Feed4QueryVariables>(sdk.feed4, variables),
45
- config);
46
- }
47
- };
48
- }
49
- export type SdkWithHooks = ReturnType<typeof getSdkWithHooks>;
@@ -1,19 +0,0 @@
1
- export function getSdkWithHooks(client: GraphQLClient, withWrapper: SdkFunctionWrapper = defaultWrapper) {
2
- const sdk = getSdk(client, withWrapper);
3
- return {
4
- ...sdk,
5
- useFeed(key: SWRKeyInterface, variables?: FeedQueryVariables, config?: SWRConfigInterface<FeedQuery, ClientError>) {
6
- return useSWR<FeedQuery, ClientError>(key, () => sdk.feed(variables), config);
7
- },
8
- useFeed2(key: SWRKeyInterface, variables: Feed2QueryVariables, config?: SWRConfigInterface<Feed2Query, ClientError>) {
9
- return useSWR<Feed2Query, ClientError>(key, () => sdk.feed2(variables), config);
10
- },
11
- useFeed3(key: SWRKeyInterface, variables?: Feed3QueryVariables, config?: SWRConfigInterface<Feed3Query, ClientError>) {
12
- return useSWR<Feed3Query, ClientError>(key, () => sdk.feed3(variables), config);
13
- },
14
- useFeed4(key: SWRKeyInterface, variables?: Feed4QueryVariables, config?: SWRConfigInterface<Feed4Query, ClientError>) {
15
- return useSWR<Feed4Query, ClientError>(key, () => sdk.feed4(variables), config);
16
- }
17
- };
18
- }
19
- export type SdkWithHooks = ReturnType<typeof getSdkWithHooks>;
@@ -1,19 +0,0 @@
1
- export function getSdkWithHooks(client: GraphQLClient, withWrapper: SdkFunctionWrapper = defaultWrapper) {
2
- const sdk = getSdk(client, withWrapper);
3
- return {
4
- ...sdk,
5
- useFeed(key: SWRKeyInterface, variables?: FeedQueryVariables, config?: SWRConfigInterface<FeedQuery, ClientError>) {
6
- return useSWR<FeedQuery, ClientError>(key, () => sdk.feed(variables), config);
7
- },
8
- useFeed2(key: SWRKeyInterface, variables: Feed2QueryVariables, config?: SWRConfigInterface<Feed2Query, ClientError>) {
9
- return useSWR<Feed2Query, ClientError>(key, () => sdk.feed2(variables), config);
10
- },
11
- useFeed3(key: SWRKeyInterface, variables?: Feed3QueryVariables, config?: SWRConfigInterface<Feed3Query, ClientError>) {
12
- return useSWR<Feed3Query, ClientError>(key, () => sdk.feed3(variables), config);
13
- },
14
- useFeed4(key: SWRKeyInterface, variables?: Feed4QueryVariables, config?: SWRConfigInterface<Feed4Query, ClientError>) {
15
- return useSWR<Feed4Query, ClientError>(key, () => sdk.feed4(variables), config);
16
- }
17
- };
18
- }
19
- export type SdkWithHooks = ReturnType<typeof getSdkWithHooks>;
@@ -1,19 +0,0 @@
1
- export function getSdkWithHooks(client: GraphQLClient, withWrapper: SdkFunctionWrapper = defaultWrapper) {
2
- const sdk = getSdk(client, withWrapper);
3
- return {
4
- ...sdk,
5
- useFeed(key: SWRKeyInterface, variables?: FeedQueryVariables, config?: SWRConfigInterface<FeedQuery, ClientError>) {
6
- return useSWR<FeedQuery, ClientError>(key, () => sdk.feed(variables), config);
7
- },
8
- useFeed2(key: SWRKeyInterface, variables: Feed2QueryVariables, config?: SWRConfigInterface<Feed2Query, ClientError>) {
9
- return useSWR<Feed2Query, ClientError>(key, () => sdk.feed2(variables), config);
10
- },
11
- useFeed3(key: SWRKeyInterface, variables?: Feed3QueryVariables, config?: SWRConfigInterface<Feed3Query, ClientError>) {
12
- return useSWR<Feed3Query, ClientError>(key, () => sdk.feed3(variables), config);
13
- },
14
- useFeed4(key: SWRKeyInterface, variables?: Feed4QueryVariables, config?: SWRConfigInterface<Feed4Query, ClientError>) {
15
- return useSWR<Feed4Query, ClientError>(key, () => sdk.feed4(variables), config);
16
- }
17
- };
18
- }
19
- export type SdkWithHooks = ReturnType<typeof getSdkWithHooks>;