graphql-codegen-typescript-react-apollo
Advanced tools
Comparing version
@@ -6,2 +6,3 @@ "use strict"; | ||
const graphql_codegen_plugin_helpers_1 = require("graphql-codegen-plugin-helpers"); | ||
const change_case_1 = require("change-case"); | ||
class ReactApolloVisitor extends graphql_codegen_visitor_plugin_common_1.ClientSideBaseVisitor { | ||
@@ -40,7 +41,7 @@ constructor(fragments, rawConfig) { | ||
const propsTypeName = operationName + 'Props'; | ||
const propsVar = `export type ${propsTypeName}<TChildProps = any> = ${this._buildHocProps(node.name.value, node.operation)} & TChildProps;`; | ||
const propsVar = `export type ${propsTypeName}<TChildProps = {}> = ${this._buildHocProps(node.name.value, node.operation)} & TChildProps;`; | ||
const mutationFn = node.operation === 'mutation' | ||
? `export type ${this.convertName(node.name.value + 'MutationFn')} = ReactApollo.MutationFn<${operationResultType}, ${operationVariablesTypes}>;` | ||
: null; | ||
const hocString = `export function ${operationName}HOC<TProps, TChildProps = any>(operationOptions: ReactApollo.OperationOption< | ||
const hocString = `export function with${operationName}<TProps, TChildProps = {}>(operationOptions: ReactApollo.OperationOption< | ||
TProps, | ||
@@ -50,3 +51,3 @@ ${operationResultType}, | ||
${propsTypeName}<TChildProps>> | undefined) { | ||
return ReactApollo.graphql<TProps, ${operationResultType}, ${operationVariablesTypes}, ${propsTypeName}<TChildProps>>(${documentVariableName}, operationOptions); | ||
return ReactApollo.with${change_case_1.titleCase(node.operation)}<TProps, ${operationResultType}, ${operationVariablesTypes}, ${propsTypeName}<TChildProps>>(${documentVariableName}, operationOptions); | ||
};`; | ||
@@ -53,0 +54,0 @@ return [propsVar, mutationFn, hocString].filter(a => a).join('\n'); |
import { ClientSideBaseVisitor, getConfigValue } from 'graphql-codegen-visitor-plugin-common'; | ||
import * as autoBind from 'auto-bind'; | ||
import { toPascalCase } from 'graphql-codegen-plugin-helpers'; | ||
import { titleCase } from 'change-case'; | ||
export class ReactApolloVisitor extends ClientSideBaseVisitor { | ||
@@ -37,7 +38,7 @@ constructor(fragments, rawConfig) { | ||
const propsTypeName = operationName + 'Props'; | ||
const propsVar = `export type ${propsTypeName}<TChildProps = any> = ${this._buildHocProps(node.name.value, node.operation)} & TChildProps;`; | ||
const propsVar = `export type ${propsTypeName}<TChildProps = {}> = ${this._buildHocProps(node.name.value, node.operation)} & TChildProps;`; | ||
const mutationFn = node.operation === 'mutation' | ||
? `export type ${this.convertName(node.name.value + 'MutationFn')} = ReactApollo.MutationFn<${operationResultType}, ${operationVariablesTypes}>;` | ||
: null; | ||
const hocString = `export function ${operationName}HOC<TProps, TChildProps = any>(operationOptions: ReactApollo.OperationOption< | ||
const hocString = `export function with${operationName}<TProps, TChildProps = {}>(operationOptions: ReactApollo.OperationOption< | ||
TProps, | ||
@@ -47,3 +48,3 @@ ${operationResultType}, | ||
${propsTypeName}<TChildProps>> | undefined) { | ||
return ReactApollo.graphql<TProps, ${operationResultType}, ${operationVariablesTypes}, ${propsTypeName}<TChildProps>>(${documentVariableName}, operationOptions); | ||
return ReactApollo.with${titleCase(node.operation)}<TProps, ${operationResultType}, ${operationVariablesTypes}, ${propsTypeName}<TChildProps>>(${documentVariableName}, operationOptions); | ||
};`; | ||
@@ -50,0 +51,0 @@ return [propsVar, mutationFn, hocString].filter(a => a).join('\n'); |
{ | ||
"name": "graphql-codegen-typescript-react-apollo", | ||
"version": "0.19.0-alpha.a74ef9c7", | ||
"version": "0.19.0-alpha.ab0b68e0", | ||
"description": "graphql-codegen-cli template for TypeScript typings for both client side and server side", | ||
@@ -15,11 +15,11 @@ "repository": "git@github.com:dotansimha/graphql-code-generator.git", | ||
"dependencies": { | ||
"graphql-codegen-plugin-helpers": "0.19.0-alpha.a74ef9c7", | ||
"graphql-codegen-visitor-plugin-common": "0.19.0-alpha.a74ef9c7", | ||
"graphql-codegen-plugin-helpers": "0.19.0-alpha.ab0b68e0", | ||
"graphql-codegen-visitor-plugin-common": "0.19.0-alpha.ab0b68e0", | ||
"tslib": "1.9.3" | ||
}, | ||
"devDependencies": { | ||
"flow-bin": "0.94.0", | ||
"flow-bin": "0.95.1", | ||
"flow-parser": "0.95.1", | ||
"graphql": "14.1.1", | ||
"graphql-codegen-testing": "0.19.0-alpha.a74ef9c7", | ||
"graphql-codegen-testing": "0.19.0-alpha.ab0b68e0", | ||
"jest": "24.5.0", | ||
@@ -26,0 +26,0 @@ "ts-jest": "24.0.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
27630
1%311
0.65%0
-100%+ Added
+ Added
- Removed
- Removed
- Removed
Updated