Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@graphql-codegen/typescript-react-apollo

Package Overview
Dependencies
Maintainers
5
Versions
4416
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@graphql-codegen/typescript-react-apollo - npm Package Compare versions

Comparing version 0.18.1-alpha.59 to 0.18.1-alpha.63

64

dist/commonjs/index.d.ts
import { PluginValidateFn, PluginFunction } from '@graphql-codegen/plugin-helpers';
import { RawClientSideBasePluginConfig } from '@graphql-codegen/visitor-plugin-common';
export interface ReactApolloRawPluginConfig extends RawClientSideBasePluginConfig {
/**
* @name withHOC
* @type boolean
* @description Customized the output by enabling/disabling the HOC.
* @default true
*
* @example
* ```yml
* generates:
* path/to/file.ts:
* plugins:
* - typescript
* - typescript-operations
* - typescript-react-apollo
* config:
* withHOC: false
* ```
*/
withHOC?: boolean;
/**
* @name withComponent
* @type boolean
* @description Customized the output by enabling/disabling the generated Component.
* @default true
*
* @example
* ```yml
* generates:
* path/to/file.ts:
* plugins:
* - typescript
* - typescript-operations
* - typescript-react-apollo
* config:
* withComponent: false
* ```
*/
withComponent?: boolean;
/**
* @name withHooks
* @type boolean
* @description Customized the output by enabling/disabling the generated React Hooks.
* @default false
*
* @example
* ```yml
* generates:
* path/to/file.ts:
* plugins:
* - typescript
* - typescript-operations
* - typescript-react-apollo
* config:
* withComponent: false
* ```
*/
withHooks?: boolean;
/**
* @name hooksImportFrom
* @type string
* @description You can specify alternative module that is exports `useQuery` `useMutation` and `useSubscription`.
* This is useful for further abstraction of some common tasks (eg. error handling).
* Filepath relative to generated file can be also specified.
* @default react-apollo-hooks
*/
hooksImportFrom?: string;
gqlImport?: string;
noGraphQLTag?: boolean;
}
export declare const plugin: PluginFunction<ReactApolloRawPluginConfig>;
export declare const validate: PluginValidateFn<any>;

7

dist/commonjs/visitor.js

@@ -6,2 +6,3 @@ "use strict";

const plugin_helpers_1 = require("@graphql-codegen/plugin-helpers");
const change_case_1 = require("change-case");
class ReactApolloVisitor extends visitor_plugin_common_1.ClientSideBaseVisitor {

@@ -40,5 +41,5 @@ 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,

@@ -48,3 +49,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);
};`;

@@ -51,0 +52,0 @@ return [propsVar, mutationFn, hocString].filter(a => a).join('\n');

import { PluginValidateFn, PluginFunction } from '@graphql-codegen/plugin-helpers';
import { RawClientSideBasePluginConfig } from '@graphql-codegen/visitor-plugin-common';
export interface ReactApolloRawPluginConfig extends RawClientSideBasePluginConfig {
/**
* @name withHOC
* @type boolean
* @description Customized the output by enabling/disabling the HOC.
* @default true
*
* @example
* ```yml
* generates:
* path/to/file.ts:
* plugins:
* - typescript
* - typescript-operations
* - typescript-react-apollo
* config:
* withHOC: false
* ```
*/
withHOC?: boolean;
/**
* @name withComponent
* @type boolean
* @description Customized the output by enabling/disabling the generated Component.
* @default true
*
* @example
* ```yml
* generates:
* path/to/file.ts:
* plugins:
* - typescript
* - typescript-operations
* - typescript-react-apollo
* config:
* withComponent: false
* ```
*/
withComponent?: boolean;
/**
* @name withHooks
* @type boolean
* @description Customized the output by enabling/disabling the generated React Hooks.
* @default false
*
* @example
* ```yml
* generates:
* path/to/file.ts:
* plugins:
* - typescript
* - typescript-operations
* - typescript-react-apollo
* config:
* withComponent: false
* ```
*/
withHooks?: boolean;
/**
* @name hooksImportFrom
* @type string
* @description You can specify alternative module that is exports `useQuery` `useMutation` and `useSubscription`.
* This is useful for further abstraction of some common tasks (eg. error handling).
* Filepath relative to generated file can be also specified.
* @default react-apollo-hooks
*/
hooksImportFrom?: string;
gqlImport?: string;
noGraphQLTag?: boolean;
}
export declare const plugin: PluginFunction<ReactApolloRawPluginConfig>;
export declare const validate: PluginValidateFn<any>;
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,5 +38,5 @@ 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,

@@ -45,3 +46,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);
};`;

@@ -48,0 +49,0 @@ return [propsVar, mutationFn, hocString].filter(a => a).join('\n');

{
"name": "@graphql-codegen/typescript-react-apollo",
"version": "0.18.1-alpha.59+c8b59c87",
"version": "0.18.1-alpha.63+3b44d0d5",
"description": "GraphQL Code Generator plugin for generating a ready-to-use React Components/HOC/Hooks based on GraphQL operations",

@@ -15,8 +15,8 @@ "repository": "git@github.com:dotansimha/graphql-code-generator.git",

"dependencies": {
"@graphql-codegen/plugin-helpers": "0.18.1-alpha.59+c8b59c87",
"@graphql-codegen/visitor-plugin-common": "0.18.1-alpha.59+c8b59c87",
"@graphql-codegen/plugin-helpers": "0.18.1-alpha.63+3b44d0d5",
"@graphql-codegen/visitor-plugin-common": "0.18.1-alpha.63+3b44d0d5",
"tslib": "1.9.3"
},
"devDependencies": {
"@graphql-codegen/testing": "0.18.1-alpha.59+c8b59c87",
"@graphql-codegen/testing": "0.18.1-alpha.63+3b44d0d5",
"flow-bin": "0.95.1",

@@ -39,3 +39,3 @@ "flow-parser": "0.95.1",

},
"gitHead": "c8b59c8737fdc9e68dd8dbb3b8640ef4d64b7aaf"
"gitHead": "3b44d0d5ef0a11fb9e6d07ca1655aab61b3068d6"
}

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc