@graphql-codegen/typescript-react-apollo 3.3.3-alpha-0814e49cc.0 → 3.3.3

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.
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@graphql-codegen/typescript-react-apollo",
3
- "version": "3.3.3-alpha-0814e49cc.0",
3
+ "version": "3.3.3",
4
4
  "description": "GraphQL Code Generator plugin for generating a ready-to-use React Components/HOC/Hooks based on GraphQL operations",
5
5
  "peerDependencies": {
6
6
  "graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0",
7
7
  "graphql-tag": "^2.0.0"
8
8
  },
9
9
  "dependencies": {
10
- "@graphql-codegen/plugin-helpers": "^2.6.1-alpha-0814e49cc.0",
11
- "@graphql-codegen/visitor-plugin-common": "2.12.1-alpha-0814e49cc.0",
10
+ "@graphql-codegen/plugin-helpers": "^2.6.2",
11
+ "@graphql-codegen/visitor-plugin-common": "2.12.1",
12
12
  "auto-bind": "~4.0.0",
13
13
  "change-case-all": "1.0.14",
14
14
  "tslib": "~2.4.0"
@@ -29,7 +29,7 @@
29
29
  "exports": {
30
30
  ".": {
31
31
  "require": {
32
- "types": "./typings/index.d.ts",
32
+ "types": "./typings/index.d.cts",
33
33
  "default": "./cjs/index.js"
34
34
  },
35
35
  "import": {
@@ -0,0 +1,193 @@
1
+ import { RawClientSideBasePluginConfig } from '@graphql-codegen/visitor-plugin-common';
2
+ /**
3
+ * @description This plugin generates React Apollo components and HOC with TypeScript typings.
4
+ *
5
+ * It extends the basic TypeScript plugins: `@graphql-codegen/typescript`, `@graphql-codegen/typescript-operations` - and thus shares a similar configuration.
6
+ */
7
+ export interface ReactApolloRawPluginConfig extends RawClientSideBasePluginConfig {
8
+ /**
9
+ * @description Customize the output by enabling/disabling the generated Component (deprecated since Apollo-Client v3). For more details: https://apollographql.com/docs/react/api/react/components
10
+ * @default false
11
+ *
12
+ * @exampleMarkdown
13
+ * ```yaml
14
+ * generates:
15
+ * path/to/file.ts:
16
+ * plugins:
17
+ * - typescript
18
+ * - typescript-operations
19
+ * - typescript-react-apollo
20
+ * config:
21
+ * withComponent: true
22
+ * ```
23
+ */
24
+ withComponent?: boolean;
25
+ /**
26
+ * @description Customize the output by enabling/disabling the HOC (deprecated since Apollo-Client v3). For more details: https://apollographql.com/docs/react/api/react/hoc
27
+ * @default false
28
+ *
29
+ * @exampleMarkdown
30
+ * ```yaml
31
+ * generates:
32
+ * path/to/file.ts:
33
+ * plugins:
34
+ * - typescript
35
+ * - typescript-operations
36
+ * - typescript-react-apollo
37
+ * config:
38
+ * withHOC: true
39
+ * ```
40
+ */
41
+ withHOC?: boolean;
42
+ /**
43
+ * @description Customized the output by enabling/disabling the generated React Hooks. For more details: https://apollographql.com/docs/react/api/react/hooks
44
+ * @default true
45
+ *
46
+ * @exampleMarkdown
47
+ * ```yaml
48
+ * generates:
49
+ * path/to/file.ts:
50
+ * plugins:
51
+ * - typescript
52
+ * - typescript-operations
53
+ * - typescript-react-apollo
54
+ * config:
55
+ * withHooks: true
56
+ * ```
57
+ */
58
+ withHooks?: boolean;
59
+ /**
60
+ * @description Customized the output by enabling/disabling the generated mutation function signature.
61
+ * @default true
62
+ *
63
+ * @exampleMarkdown
64
+ * ```yaml
65
+ * generates:
66
+ * path/to/file.ts:
67
+ * plugins:
68
+ * - typescript
69
+ * - typescript-operations
70
+ * - typescript-react-apollo
71
+ * config:
72
+ * withMutationFn: true
73
+ * ```
74
+ */
75
+ withMutationFn?: boolean;
76
+ /**
77
+ * @description Enable generating a function to be used with refetchQueries
78
+ * @default false
79
+ *
80
+ * @exampleMarkdown
81
+ * ```yaml
82
+ * generates:
83
+ * path/to/file.ts:
84
+ * plugins:
85
+ * - typescript
86
+ * - typescript-operations
87
+ * - typescript-react-apollo
88
+ * config:
89
+ * withRefetchFn: false
90
+ * ```
91
+ */
92
+ withRefetchFn?: boolean;
93
+ /**
94
+ * @description Customize the package where apollo-react common lib is loaded from.
95
+ * @default "@apollo/react-common"
96
+ */
97
+ apolloReactCommonImportFrom?: string;
98
+ /**
99
+ * @description Customize the package where apollo-react component lib is loaded from.
100
+ * @default "@apollo/react-components"
101
+ */
102
+ apolloReactComponentsImportFrom?: string;
103
+ /**
104
+ * @description Customize the package where apollo-react HOC lib is loaded from.
105
+ * @default "@apollo/react-hoc"
106
+ */
107
+ apolloReactHocImportFrom?: string;
108
+ /**
109
+ * @description Customize the package where apollo-react hooks lib is loaded from.
110
+ * @default "@apollo/react-hooks"
111
+ */
112
+ apolloReactHooksImportFrom?: string;
113
+ /**
114
+ * @description You can specify a suffix that gets attached to the name of the generated component.
115
+ * @default Component
116
+ */
117
+ componentSuffix?: string;
118
+ /**
119
+ * @description Sets the version of react-apollo.
120
+ * If you are using the old (deprecated) package of `react-apollo`, please set this configuration to `2`.
121
+ * If you are using Apollo-Client v3, please set this to `3`.
122
+ * @default 3
123
+ *
124
+ * @exampleMarkdown
125
+ * ```yaml
126
+ * generates:
127
+ * path/to/file.ts:
128
+ * plugins:
129
+ * - typescript
130
+ * - typescript-operations
131
+ * - typescript-react-apollo
132
+ * config:
133
+ * reactApolloVersion: 2
134
+ * ```
135
+ */
136
+ reactApolloVersion?: 2 | 3;
137
+ /**
138
+ * @description Customized the output by enabling/disabling the generated result type.
139
+ * @default true
140
+ *
141
+ * @exampleMarkdown
142
+ * ```yaml
143
+ * generates:
144
+ * path/to/file.ts:
145
+ * plugins:
146
+ * - typescript
147
+ * - typescript-operations
148
+ * - typescript-react-apollo
149
+ * config:
150
+ * withResultType: true
151
+ * ```
152
+ */
153
+ withResultType?: boolean;
154
+ /**
155
+ * @description Customized the output by enabling/disabling the generated mutation option type.
156
+ * @default true
157
+ *
158
+ * @exampleMarkdown
159
+ * ```yaml
160
+ * generates:
161
+ * path/to/file.ts:
162
+ * plugins:
163
+ * - typescript
164
+ * - typescript-operations
165
+ * - typescript-react-apollo
166
+ * config:
167
+ * withMutationOptionsType: true
168
+ * ```
169
+ */
170
+ withMutationOptionsType?: boolean;
171
+ /**
172
+ * @description Allows you to enable/disable the generation of docblocks in generated code.
173
+ * Some IDE's (like VSCode) add extra inline information with docblocks, you can disable this feature if your preferred IDE does not.
174
+ * @default true
175
+ *
176
+ * @exampleMarkdown
177
+ * ```yaml
178
+ * generates:
179
+ * path/to/file.ts:
180
+ * plugins:
181
+ * - typescript
182
+ * - typescript-operations
183
+ * - typescript-react-apollo
184
+ * config:
185
+ * addDocBlocks: true
186
+ * ```
187
+ */
188
+ addDocBlocks?: boolean;
189
+ defaultBaseOptions?: {
190
+ [key: string]: string;
191
+ };
192
+ hooksSuffix?: string;
193
+ }
@@ -0,0 +1,6 @@
1
+ import { Types, PluginValidateFn, PluginFunction } from '@graphql-codegen/plugin-helpers';
2
+ import { ReactApolloVisitor } from './visitor.cjs';
3
+ import { ReactApolloRawPluginConfig } from './config.cjs';
4
+ export declare const plugin: PluginFunction<ReactApolloRawPluginConfig, Types.ComplexPluginOutput>;
5
+ export declare const validate: PluginValidateFn<any>;
6
+ export { ReactApolloVisitor };
@@ -0,0 +1,54 @@
1
+ import { ClientSideBaseVisitor, ClientSideBasePluginConfig, LoadedFragment } from '@graphql-codegen/visitor-plugin-common';
2
+ import { ReactApolloRawPluginConfig } from './config.cjs';
3
+ import { OperationDefinitionNode, GraphQLSchema } from 'graphql';
4
+ import { Types } from '@graphql-codegen/plugin-helpers';
5
+ export interface ReactApolloPluginConfig extends ClientSideBasePluginConfig {
6
+ withComponent: boolean;
7
+ withHOC: boolean;
8
+ withHooks: boolean;
9
+ withMutationFn: boolean;
10
+ withRefetchFn: boolean;
11
+ apolloReactCommonImportFrom: string;
12
+ apolloReactComponentsImportFrom: string;
13
+ apolloReactHocImportFrom: string;
14
+ apolloReactHooksImportFrom: string;
15
+ componentSuffix: string;
16
+ reactApolloVersion: 2 | 3;
17
+ withResultType: boolean;
18
+ withMutationOptionsType: boolean;
19
+ addDocBlocks: boolean;
20
+ defaultBaseOptions: {
21
+ [key: string]: string;
22
+ };
23
+ hooksSuffix: string;
24
+ }
25
+ export declare class ReactApolloVisitor extends ClientSideBaseVisitor<ReactApolloRawPluginConfig, ReactApolloPluginConfig> {
26
+ protected rawConfig: ReactApolloRawPluginConfig;
27
+ private _externalImportPrefix;
28
+ private imports;
29
+ constructor(schema: GraphQLSchema, fragments: LoadedFragment[], rawConfig: ReactApolloRawPluginConfig, documents: Types.DocumentFile[]);
30
+ private getImportStatement;
31
+ private getReactImport;
32
+ private getApolloReactCommonIdentifier;
33
+ private getApolloReactHooksIdentifier;
34
+ private usesExternalHooksOnly;
35
+ private getApolloReactCommonImport;
36
+ private getApolloReactComponentsImport;
37
+ private getApolloReactHocImport;
38
+ private getApolloReactHooksImport;
39
+ private getOmitDeclaration;
40
+ private getDefaultOptions;
41
+ private getDocumentNodeVariable;
42
+ getImports(): string[];
43
+ private _buildHocProps;
44
+ private _buildMutationFn;
45
+ private _buildOperationHoc;
46
+ private _buildComponent;
47
+ private _buildHooksJSDoc;
48
+ private _buildHooks;
49
+ private _getHookSuffix;
50
+ private _buildResultType;
51
+ private _buildWithMutationOptionsType;
52
+ private _buildRefetchFn;
53
+ protected buildOperation(node: OperationDefinitionNode, documentVariableName: string, operationType: string, operationResultType: string, operationVariablesTypes: string, hasRequiredVariables: boolean): string;
54
+ }