@acrool/graphql-codegen-rtk-query
Advanced tools
Comparing version 0.0.3-test.0 to 0.0.3-test.1
@@ -16,3 +16,4 @@ import { GraphQLSchema, OperationDefinitionNode } from 'graphql'; | ||
private injectTransformResponse; | ||
generateSubscriptionHook(node: OperationDefinitionNode, documentVariableName: string, operationName: string, operationResultType: string, operationVariablesTypes: string, hasRequiredVariables: boolean): string; | ||
protected buildOperation(node: OperationDefinitionNode, documentVariableName: string, operationType: 'Query' | 'Mutation' | 'Subscription', operationResultType: string, operationVariablesTypes: string, hasRequiredVariables: boolean): string; | ||
} |
@@ -72,4 +72,21 @@ "use strict"; | ||
} | ||
generateSubscriptionHook(node, documentVariableName, operationName, operationResultType, operationVariablesTypes, hasRequiredVariables) { | ||
const variables = `args${hasRequiredVariables ? '' : '?'}: SubscriptionHookOptions<TData, ${operationVariablesTypes}>`; | ||
// const hookConfig = this.visitor.queryMethodMap; | ||
// this.visitor.reactQueryHookIdentifiersInUse.add(hookConfig.subscription.hook); | ||
// this.visitor.reactQueryOptionsIdentifiersInUse.add(hookConfig.subscription.options); | ||
const typedFetcher = `useSubscription<TData, ${operationVariablesTypes}>`; | ||
; | ||
const impl = `${typedFetcher}(gql(${documentVariableName}), args);`; | ||
return `export const use${operationName} = < | ||
TData = ${operationResultType}, | ||
TError = unknown | ||
>( | ||
${variables}, | ||
) => | ||
${impl} | ||
`; | ||
} | ||
buildOperation(node, documentVariableName, operationType, operationResultType, operationVariablesTypes, hasRequiredVariables) { | ||
var _a, _b; | ||
var _a; | ||
operationResultType = this._externalImportPrefix + operationResultType; | ||
@@ -80,7 +97,9 @@ operationVariablesTypes = this._externalImportPrefix + operationVariablesTypes; | ||
return ''; | ||
if (operationType === 'Subscription') { | ||
// eslint-disable-next-line no-console | ||
console.warn(`Plugin "typescript-rtk-query" does not support GraphQL Subscriptions at the moment! Skipping "${(_b = node.name) === null || _b === void 0 ? void 0 : _b.value}"...`); | ||
return ''; | ||
} | ||
// if (operationType === 'Subscription') { | ||
// // eslint-disable-next-line no-console | ||
// console.warn( | ||
// `Plugin "typescript-rtk-query" does not support GraphQL Subscriptions at the moment! Skipping "${node.name?.value}"...`, | ||
// ); | ||
// return ''; | ||
// } | ||
const Generics = `${operationResultType}, IUseFetcherArgs<${operationVariablesTypes}>${hasRequiredVariables ? '' : ' | void'}`; | ||
@@ -103,2 +122,5 @@ const operationTypeString = operationType.toLowerCase(); | ||
} | ||
if (operationType === 'Subscription') { | ||
this._hooks.push(this.generateSubscriptionHook(node, documentVariableName, operationName, operationResultType, operationVariablesTypes, hasRequiredVariables)); | ||
} | ||
} | ||
@@ -105,0 +127,0 @@ return ''; |
{ | ||
"name": "@acrool/graphql-codegen-rtk-query", | ||
"version": "0.0.3-test.0", | ||
"version": "0.0.3-test.1", | ||
"description": "trk-query for graphql-code-generator", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20759
335