@graphql-codegen/typescript-react-apollo 3.2.17 → 3.2.18-alpha-5d16266dd.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.
- package/cjs/config.js +2 -0
- package/cjs/index.js +38 -0
- package/cjs/package.json +1 -0
- package/{index.js → cjs/visitor.js} +38 -75
- package/esm/config.js +1 -0
- package/esm/index.js +33 -0
- package/{index.mjs → esm/visitor.js} +3 -37
- package/package.json +21 -14
- package/{config.d.ts → typings/config.d.ts} +0 -0
- package/{index.d.ts → typings/index.d.ts} +2 -2
- package/{visitor.d.ts → typings/visitor.d.ts} +1 -1
package/cjs/config.js
ADDED
package/cjs/index.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ReactApolloVisitor = exports.validate = exports.plugin = void 0;
|
|
4
|
+
const plugin_helpers_1 = require("@graphql-codegen/plugin-helpers");
|
|
5
|
+
const graphql_1 = require("graphql");
|
|
6
|
+
const visitor_js_1 = require("./visitor.js");
|
|
7
|
+
Object.defineProperty(exports, "ReactApolloVisitor", { enumerable: true, get: function () { return visitor_js_1.ReactApolloVisitor; } });
|
|
8
|
+
const path_1 = require("path");
|
|
9
|
+
const plugin = (schema, documents, config) => {
|
|
10
|
+
const allAst = (0, graphql_1.concatAST)(documents.map(v => v.document));
|
|
11
|
+
const allFragments = [
|
|
12
|
+
...allAst.definitions.filter(d => d.kind === graphql_1.Kind.FRAGMENT_DEFINITION).map(fragmentDef => ({
|
|
13
|
+
node: fragmentDef,
|
|
14
|
+
name: fragmentDef.name.value,
|
|
15
|
+
onType: fragmentDef.typeCondition.name.value,
|
|
16
|
+
isExternal: false,
|
|
17
|
+
})),
|
|
18
|
+
...(config.externalFragments || []),
|
|
19
|
+
];
|
|
20
|
+
const visitor = new visitor_js_1.ReactApolloVisitor(schema, allFragments, config, documents);
|
|
21
|
+
const visitorResult = (0, plugin_helpers_1.oldVisit)(allAst, { leave: visitor });
|
|
22
|
+
return {
|
|
23
|
+
prepend: visitor.getImports(),
|
|
24
|
+
content: [visitor.fragments, ...visitorResult.definitions.filter(t => typeof t === 'string')].join('\n'),
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
exports.plugin = plugin;
|
|
28
|
+
const validate = async (schema, documents, config, outputFile) => {
|
|
29
|
+
if (config.withComponent === true) {
|
|
30
|
+
if ((0, path_1.extname)(outputFile) !== '.tsx') {
|
|
31
|
+
throw new Error(`Plugin "typescript-react-apollo" requires extension to be ".tsx" when withComponent: true is set!`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
else if ((0, path_1.extname)(outputFile) !== '.ts' && (0, path_1.extname)(outputFile) !== '.tsx') {
|
|
35
|
+
throw new Error(`Plugin "typescript-react-apollo" requires extension to be ".ts" or ".tsx"!`);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
exports.validate = validate;
|
package/cjs/package.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -1,50 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const visitorPluginCommon = require('@graphql-codegen/visitor-plugin-common');
|
|
10
|
-
const autoBind = _interopDefault(require('auto-bind'));
|
|
11
|
-
const changeCaseAll = require('change-case-all');
|
|
12
|
-
const path = require('path');
|
|
13
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ReactApolloVisitor = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const visitor_plugin_common_1 = require("@graphql-codegen/visitor-plugin-common");
|
|
6
|
+
const auto_bind_1 = tslib_1.__importDefault(require("auto-bind"));
|
|
7
|
+
const graphql_1 = require("graphql");
|
|
8
|
+
const change_case_all_1 = require("change-case-all");
|
|
14
9
|
const APOLLO_CLIENT_3_UNIFIED_PACKAGE = `@apollo/client`;
|
|
15
10
|
const GROUPED_APOLLO_CLIENT_3_IDENTIFIER = 'Apollo';
|
|
16
11
|
function hasRequiredVariables(node) {
|
|
17
12
|
var _a, _b;
|
|
18
|
-
return ((_b = (_a = node.variableDefinitions) === null || _a === void 0 ? void 0 : _a.some(variableDef => variableDef.type.kind ===
|
|
13
|
+
return ((_b = (_a = node.variableDefinitions) === null || _a === void 0 ? void 0 : _a.some(variableDef => variableDef.type.kind === graphql_1.Kind.NON_NULL_TYPE && !variableDef.defaultValue)) !== null && _b !== void 0 ? _b : false);
|
|
19
14
|
}
|
|
20
|
-
class ReactApolloVisitor extends
|
|
15
|
+
class ReactApolloVisitor extends visitor_plugin_common_1.ClientSideBaseVisitor {
|
|
21
16
|
constructor(schema, fragments, rawConfig, documents) {
|
|
22
17
|
super(schema, fragments, rawConfig, {
|
|
23
|
-
componentSuffix:
|
|
24
|
-
withHOC:
|
|
25
|
-
withComponent:
|
|
26
|
-
withHooks:
|
|
27
|
-
withMutationFn:
|
|
28
|
-
withRefetchFn:
|
|
29
|
-
apolloReactCommonImportFrom:
|
|
30
|
-
apolloReactComponentsImportFrom:
|
|
18
|
+
componentSuffix: (0, visitor_plugin_common_1.getConfigValue)(rawConfig.componentSuffix, 'Component'),
|
|
19
|
+
withHOC: (0, visitor_plugin_common_1.getConfigValue)(rawConfig.withHOC, false),
|
|
20
|
+
withComponent: (0, visitor_plugin_common_1.getConfigValue)(rawConfig.withComponent, false),
|
|
21
|
+
withHooks: (0, visitor_plugin_common_1.getConfigValue)(rawConfig.withHooks, true),
|
|
22
|
+
withMutationFn: (0, visitor_plugin_common_1.getConfigValue)(rawConfig.withMutationFn, true),
|
|
23
|
+
withRefetchFn: (0, visitor_plugin_common_1.getConfigValue)(rawConfig.withRefetchFn, false),
|
|
24
|
+
apolloReactCommonImportFrom: (0, visitor_plugin_common_1.getConfigValue)(rawConfig.apolloReactCommonImportFrom, rawConfig.reactApolloVersion === 2 ? '@apollo/react-common' : APOLLO_CLIENT_3_UNIFIED_PACKAGE),
|
|
25
|
+
apolloReactComponentsImportFrom: (0, visitor_plugin_common_1.getConfigValue)(rawConfig.apolloReactComponentsImportFrom, rawConfig.reactApolloVersion === 2
|
|
31
26
|
? '@apollo/react-components'
|
|
32
27
|
: `${APOLLO_CLIENT_3_UNIFIED_PACKAGE}/react/components`),
|
|
33
|
-
apolloReactHocImportFrom:
|
|
34
|
-
apolloReactHooksImportFrom:
|
|
35
|
-
reactApolloVersion:
|
|
36
|
-
withResultType:
|
|
37
|
-
withMutationOptionsType:
|
|
38
|
-
addDocBlocks:
|
|
39
|
-
defaultBaseOptions:
|
|
40
|
-
gqlImport:
|
|
41
|
-
hooksSuffix:
|
|
28
|
+
apolloReactHocImportFrom: (0, visitor_plugin_common_1.getConfigValue)(rawConfig.apolloReactHocImportFrom, rawConfig.reactApolloVersion === 2 ? '@apollo/react-hoc' : `${APOLLO_CLIENT_3_UNIFIED_PACKAGE}/react/hoc`),
|
|
29
|
+
apolloReactHooksImportFrom: (0, visitor_plugin_common_1.getConfigValue)(rawConfig.apolloReactHooksImportFrom, rawConfig.reactApolloVersion === 2 ? '@apollo/react-hooks' : APOLLO_CLIENT_3_UNIFIED_PACKAGE),
|
|
30
|
+
reactApolloVersion: (0, visitor_plugin_common_1.getConfigValue)(rawConfig.reactApolloVersion, 3),
|
|
31
|
+
withResultType: (0, visitor_plugin_common_1.getConfigValue)(rawConfig.withResultType, true),
|
|
32
|
+
withMutationOptionsType: (0, visitor_plugin_common_1.getConfigValue)(rawConfig.withMutationOptionsType, true),
|
|
33
|
+
addDocBlocks: (0, visitor_plugin_common_1.getConfigValue)(rawConfig.addDocBlocks, true),
|
|
34
|
+
defaultBaseOptions: (0, visitor_plugin_common_1.getConfigValue)(rawConfig.defaultBaseOptions, {}),
|
|
35
|
+
gqlImport: (0, visitor_plugin_common_1.getConfigValue)(rawConfig.gqlImport, rawConfig.reactApolloVersion === 2 ? null : `${APOLLO_CLIENT_3_UNIFIED_PACKAGE}#gql`),
|
|
36
|
+
hooksSuffix: (0, visitor_plugin_common_1.getConfigValue)(rawConfig.hooksSuffix, ''),
|
|
42
37
|
});
|
|
43
38
|
this.rawConfig = rawConfig;
|
|
44
39
|
this.imports = new Set();
|
|
45
40
|
this._externalImportPrefix = this.config.importOperationTypesFrom ? `${this.config.importOperationTypesFrom}.` : '';
|
|
46
41
|
this._documents = documents;
|
|
47
|
-
|
|
42
|
+
(0, auto_bind_1.default)(this);
|
|
48
43
|
}
|
|
49
44
|
getImportStatement(isTypeImport) {
|
|
50
45
|
return isTypeImport && this.config.useTypeImports ? 'import type' : 'import';
|
|
@@ -87,14 +82,14 @@ class ReactApolloVisitor extends visitorPluginCommon.ClientSideBaseVisitor {
|
|
|
87
82
|
return `${this.getImportStatement(isTypeImport)} * as ${this.getApolloReactHooksIdentifier()} from '${this.config.apolloReactHooksImportFrom}';`;
|
|
88
83
|
}
|
|
89
84
|
getOmitDeclaration() {
|
|
90
|
-
return
|
|
85
|
+
return visitor_plugin_common_1.OMIT_TYPE;
|
|
91
86
|
}
|
|
92
87
|
getDefaultOptions() {
|
|
93
88
|
return `const defaultOptions = ${JSON.stringify(this.config.defaultBaseOptions)} as const;`;
|
|
94
89
|
}
|
|
95
90
|
getDocumentNodeVariable(node, documentVariableName) {
|
|
96
91
|
var _a, _b;
|
|
97
|
-
return this.config.documentMode ===
|
|
92
|
+
return this.config.documentMode === visitor_plugin_common_1.DocumentMode.external
|
|
98
93
|
? `Operations.${(_b = (_a = node.name) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : ''}`
|
|
99
94
|
: documentVariableName;
|
|
100
95
|
}
|
|
@@ -108,8 +103,8 @@ class ReactApolloVisitor extends visitorPluginCommon.ClientSideBaseVisitor {
|
|
|
108
103
|
}
|
|
109
104
|
_buildHocProps(operationName, operationType) {
|
|
110
105
|
const typeVariableName = this._externalImportPrefix +
|
|
111
|
-
this.convertName(operationName +
|
|
112
|
-
const variablesVarName = this._externalImportPrefix + this.convertName(operationName +
|
|
106
|
+
this.convertName(operationName + (0, change_case_all_1.pascalCase)(operationType) + this._parsedConfig.operationResultSuffix);
|
|
107
|
+
const variablesVarName = this._externalImportPrefix + this.convertName(operationName + (0, change_case_all_1.pascalCase)(operationType) + 'Variables');
|
|
113
108
|
const typeArgs = `<${typeVariableName}, ${variablesVarName}>`;
|
|
114
109
|
if (operationType === 'mutation') {
|
|
115
110
|
this.imports.add(this.getApolloReactCommonImport(true));
|
|
@@ -142,8 +137,8 @@ class ReactApolloVisitor extends visitorPluginCommon.ClientSideBaseVisitor {
|
|
|
142
137
|
${operationResultType},
|
|
143
138
|
${operationVariablesTypes},
|
|
144
139
|
${propsTypeName}<TChildProps, TDataName>>) {
|
|
145
|
-
return ApolloReactHoc.with${
|
|
146
|
-
alias: '${
|
|
140
|
+
return ApolloReactHoc.with${(0, change_case_all_1.pascalCase)(node.operation)}<TProps, ${operationResultType}, ${operationVariablesTypes}, ${propsTypeName}<TChildProps, TDataName>>(${this.getDocumentNodeVariable(node, documentVariableName)}, {
|
|
141
|
+
alias: '${(0, change_case_all_1.camelCase)(operationName)}',
|
|
147
142
|
...operationOptions
|
|
148
143
|
});
|
|
149
144
|
};`;
|
|
@@ -200,7 +195,7 @@ class ReactApolloVisitor extends visitorPluginCommon.ClientSideBaseVisitor {
|
|
|
200
195
|
* - A mutate function that you can call at any time to execute the mutation
|
|
201
196
|
* - An object with fields that represent the current status of the mutation's execution`;
|
|
202
197
|
const mutationExample = `
|
|
203
|
-
* const [${
|
|
198
|
+
* const [${(0, change_case_all_1.camelCase)(operationName)}, { data, loading, error }] = use${operationName}({
|
|
204
199
|
* variables: {${variableString}
|
|
205
200
|
* },
|
|
206
201
|
* });`;
|
|
@@ -238,7 +233,7 @@ class ReactApolloVisitor extends visitorPluginCommon.ClientSideBaseVisitor {
|
|
|
238
233
|
const hookResults = [`export type ${operationName}HookResult = ReturnType<typeof use${operationName}>;`];
|
|
239
234
|
if (operationType === 'Query') {
|
|
240
235
|
const lazyOperationName = this.convertName(nodeName, {
|
|
241
|
-
suffix:
|
|
236
|
+
suffix: (0, change_case_all_1.pascalCase)('LazyQuery'),
|
|
242
237
|
useTypesPrefix: false,
|
|
243
238
|
}) + this.config.hooksSuffix;
|
|
244
239
|
hookFns.push(`export function use${lazyOperationName}(baseOptions?: ${this.getApolloReactHooksIdentifier()}.LazyQueryHookOptions<${operationResultType}, ${operationVariablesTypes}>) {
|
|
@@ -254,12 +249,12 @@ class ReactApolloVisitor extends visitorPluginCommon.ClientSideBaseVisitor {
|
|
|
254
249
|
return '';
|
|
255
250
|
}
|
|
256
251
|
if (!this.config.dedupeOperationSuffix) {
|
|
257
|
-
return
|
|
252
|
+
return (0, change_case_all_1.pascalCase)(operationType);
|
|
258
253
|
}
|
|
259
254
|
if (name.includes('Query') || name.includes('Mutation') || name.includes('Subscription')) {
|
|
260
255
|
return '';
|
|
261
256
|
}
|
|
262
|
-
return
|
|
257
|
+
return (0, change_case_all_1.pascalCase)(operationType);
|
|
263
258
|
}
|
|
264
259
|
_buildResultType(node, operationType, operationResultType, operationVariablesTypes) {
|
|
265
260
|
var _a, _b;
|
|
@@ -335,36 +330,4 @@ class ReactApolloVisitor extends visitorPluginCommon.ClientSideBaseVisitor {
|
|
|
335
330
|
return [mutationFn, component, hoc, hooks, resultType, mutationOptionsType, refetchFn].filter(a => a).join('\n');
|
|
336
331
|
}
|
|
337
332
|
}
|
|
338
|
-
|
|
339
|
-
const plugin = (schema, documents, config) => {
|
|
340
|
-
const allAst = graphql.concatAST(documents.map(v => v.document));
|
|
341
|
-
const allFragments = [
|
|
342
|
-
...allAst.definitions.filter(d => d.kind === graphql.Kind.FRAGMENT_DEFINITION).map(fragmentDef => ({
|
|
343
|
-
node: fragmentDef,
|
|
344
|
-
name: fragmentDef.name.value,
|
|
345
|
-
onType: fragmentDef.typeCondition.name.value,
|
|
346
|
-
isExternal: false,
|
|
347
|
-
})),
|
|
348
|
-
...(config.externalFragments || []),
|
|
349
|
-
];
|
|
350
|
-
const visitor = new ReactApolloVisitor(schema, allFragments, config, documents);
|
|
351
|
-
const visitorResult = pluginHelpers.oldVisit(allAst, { leave: visitor });
|
|
352
|
-
return {
|
|
353
|
-
prepend: visitor.getImports(),
|
|
354
|
-
content: [visitor.fragments, ...visitorResult.definitions.filter(t => typeof t === 'string')].join('\n'),
|
|
355
|
-
};
|
|
356
|
-
};
|
|
357
|
-
const validate = async (schema, documents, config, outputFile) => {
|
|
358
|
-
if (config.withComponent === true) {
|
|
359
|
-
if (path.extname(outputFile) !== '.tsx') {
|
|
360
|
-
throw new Error(`Plugin "typescript-react-apollo" requires extension to be ".tsx" when withComponent: true is set!`);
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
else if (path.extname(outputFile) !== '.ts' && path.extname(outputFile) !== '.tsx') {
|
|
364
|
-
throw new Error(`Plugin "typescript-react-apollo" requires extension to be ".ts" or ".tsx"!`);
|
|
365
|
-
}
|
|
366
|
-
};
|
|
367
|
-
|
|
368
333
|
exports.ReactApolloVisitor = ReactApolloVisitor;
|
|
369
|
-
exports.plugin = plugin;
|
|
370
|
-
exports.validate = validate;
|
package/esm/config.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/esm/index.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { oldVisit } from '@graphql-codegen/plugin-helpers';
|
|
2
|
+
import { concatAST, Kind } from 'graphql';
|
|
3
|
+
import { ReactApolloVisitor } from './visitor.js';
|
|
4
|
+
import { extname } from 'path';
|
|
5
|
+
export const plugin = (schema, documents, config) => {
|
|
6
|
+
const allAst = concatAST(documents.map(v => v.document));
|
|
7
|
+
const allFragments = [
|
|
8
|
+
...allAst.definitions.filter(d => d.kind === Kind.FRAGMENT_DEFINITION).map(fragmentDef => ({
|
|
9
|
+
node: fragmentDef,
|
|
10
|
+
name: fragmentDef.name.value,
|
|
11
|
+
onType: fragmentDef.typeCondition.name.value,
|
|
12
|
+
isExternal: false,
|
|
13
|
+
})),
|
|
14
|
+
...(config.externalFragments || []),
|
|
15
|
+
];
|
|
16
|
+
const visitor = new ReactApolloVisitor(schema, allFragments, config, documents);
|
|
17
|
+
const visitorResult = oldVisit(allAst, { leave: visitor });
|
|
18
|
+
return {
|
|
19
|
+
prepend: visitor.getImports(),
|
|
20
|
+
content: [visitor.fragments, ...visitorResult.definitions.filter(t => typeof t === 'string')].join('\n'),
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export const validate = async (schema, documents, config, outputFile) => {
|
|
24
|
+
if (config.withComponent === true) {
|
|
25
|
+
if (extname(outputFile) !== '.tsx') {
|
|
26
|
+
throw new Error(`Plugin "typescript-react-apollo" requires extension to be ".tsx" when withComponent: true is set!`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
else if (extname(outputFile) !== '.ts' && extname(outputFile) !== '.tsx') {
|
|
30
|
+
throw new Error(`Plugin "typescript-react-apollo" requires extension to be ".ts" or ".tsx"!`);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
export { ReactApolloVisitor };
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Kind, concatAST } from 'graphql';
|
|
3
|
-
import { ClientSideBaseVisitor, getConfigValue, OMIT_TYPE, DocumentMode } from '@graphql-codegen/visitor-plugin-common';
|
|
1
|
+
import { ClientSideBaseVisitor, getConfigValue, OMIT_TYPE, DocumentMode, } from '@graphql-codegen/visitor-plugin-common';
|
|
4
2
|
import autoBind from 'auto-bind';
|
|
3
|
+
import { Kind } from 'graphql';
|
|
5
4
|
import { pascalCase, camelCase } from 'change-case-all';
|
|
6
|
-
import { extname } from 'path';
|
|
7
|
-
|
|
8
5
|
const APOLLO_CLIENT_3_UNIFIED_PACKAGE = `@apollo/client`;
|
|
9
6
|
const GROUPED_APOLLO_CLIENT_3_IDENTIFIER = 'Apollo';
|
|
10
7
|
function hasRequiredVariables(node) {
|
|
11
8
|
var _a, _b;
|
|
12
9
|
return ((_b = (_a = node.variableDefinitions) === null || _a === void 0 ? void 0 : _a.some(variableDef => variableDef.type.kind === Kind.NON_NULL_TYPE && !variableDef.defaultValue)) !== null && _b !== void 0 ? _b : false);
|
|
13
10
|
}
|
|
14
|
-
class ReactApolloVisitor extends ClientSideBaseVisitor {
|
|
11
|
+
export class ReactApolloVisitor extends ClientSideBaseVisitor {
|
|
15
12
|
constructor(schema, fragments, rawConfig, documents) {
|
|
16
13
|
super(schema, fragments, rawConfig, {
|
|
17
14
|
componentSuffix: getConfigValue(rawConfig.componentSuffix, 'Component'),
|
|
@@ -329,34 +326,3 @@ class ReactApolloVisitor extends ClientSideBaseVisitor {
|
|
|
329
326
|
return [mutationFn, component, hoc, hooks, resultType, mutationOptionsType, refetchFn].filter(a => a).join('\n');
|
|
330
327
|
}
|
|
331
328
|
}
|
|
332
|
-
|
|
333
|
-
const plugin = (schema, documents, config) => {
|
|
334
|
-
const allAst = concatAST(documents.map(v => v.document));
|
|
335
|
-
const allFragments = [
|
|
336
|
-
...allAst.definitions.filter(d => d.kind === Kind.FRAGMENT_DEFINITION).map(fragmentDef => ({
|
|
337
|
-
node: fragmentDef,
|
|
338
|
-
name: fragmentDef.name.value,
|
|
339
|
-
onType: fragmentDef.typeCondition.name.value,
|
|
340
|
-
isExternal: false,
|
|
341
|
-
})),
|
|
342
|
-
...(config.externalFragments || []),
|
|
343
|
-
];
|
|
344
|
-
const visitor = new ReactApolloVisitor(schema, allFragments, config, documents);
|
|
345
|
-
const visitorResult = oldVisit(allAst, { leave: visitor });
|
|
346
|
-
return {
|
|
347
|
-
prepend: visitor.getImports(),
|
|
348
|
-
content: [visitor.fragments, ...visitorResult.definitions.filter(t => typeof t === 'string')].join('\n'),
|
|
349
|
-
};
|
|
350
|
-
};
|
|
351
|
-
const validate = async (schema, documents, config, outputFile) => {
|
|
352
|
-
if (config.withComponent === true) {
|
|
353
|
-
if (extname(outputFile) !== '.tsx') {
|
|
354
|
-
throw new Error(`Plugin "typescript-react-apollo" requires extension to be ".tsx" when withComponent: true is set!`);
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
else if (extname(outputFile) !== '.ts' && extname(outputFile) !== '.tsx') {
|
|
358
|
-
throw new Error(`Plugin "typescript-react-apollo" requires extension to be ".ts" or ".tsx"!`);
|
|
359
|
-
}
|
|
360
|
-
};
|
|
361
|
-
|
|
362
|
-
export { ReactApolloVisitor, plugin, validate };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/typescript-react-apollo",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.18-alpha-5d16266dd.0",
|
|
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",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@graphql-codegen/plugin-helpers": "^2.4.0",
|
|
11
|
-
"@graphql-codegen/visitor-plugin-common": "2.
|
|
11
|
+
"@graphql-codegen/visitor-plugin-common": "2.11.0-alpha-5d16266dd.0",
|
|
12
12
|
"auto-bind": "~4.0.0",
|
|
13
13
|
"change-case-all": "1.0.14",
|
|
14
14
|
"tslib": "~2.4.0"
|
|
@@ -19,21 +19,28 @@
|
|
|
19
19
|
"directory": "packages/plugins/typescript/react-apollo"
|
|
20
20
|
},
|
|
21
21
|
"license": "MIT",
|
|
22
|
-
"main": "index.js",
|
|
23
|
-
"module": "index.
|
|
24
|
-
"typings": "index.d.ts",
|
|
22
|
+
"main": "cjs/index.js",
|
|
23
|
+
"module": "esm/index.js",
|
|
24
|
+
"typings": "typings/index.d.ts",
|
|
25
25
|
"typescript": {
|
|
26
|
-
"definition": "index.d.ts"
|
|
26
|
+
"definition": "typings/index.d.ts"
|
|
27
27
|
},
|
|
28
|
+
"type": "module",
|
|
28
29
|
"exports": {
|
|
29
|
-
"./package.json": "./package.json",
|
|
30
30
|
".": {
|
|
31
|
-
"require":
|
|
32
|
-
|
|
31
|
+
"require": {
|
|
32
|
+
"types": "./typings/index.d.ts",
|
|
33
|
+
"default": "./cjs/index.js"
|
|
34
|
+
},
|
|
35
|
+
"import": {
|
|
36
|
+
"types": "./typings/index.d.ts",
|
|
37
|
+
"default": "./esm/index.js"
|
|
38
|
+
},
|
|
39
|
+
"default": {
|
|
40
|
+
"types": "./typings/index.d.ts",
|
|
41
|
+
"default": "./esm/index.js"
|
|
42
|
+
}
|
|
33
43
|
},
|
|
34
|
-
"
|
|
35
|
-
"require": "./*.js",
|
|
36
|
-
"import": "./*.mjs"
|
|
37
|
-
}
|
|
44
|
+
"./package.json": "./package.json"
|
|
38
45
|
}
|
|
39
|
-
}
|
|
46
|
+
}
|
|
File without changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Types, PluginValidateFn, PluginFunction } from '@graphql-codegen/plugin-helpers';
|
|
2
|
-
import { ReactApolloVisitor } from './visitor';
|
|
3
|
-
import { ReactApolloRawPluginConfig } from './config';
|
|
2
|
+
import { ReactApolloVisitor } from './visitor.js';
|
|
3
|
+
import { ReactApolloRawPluginConfig } from './config.js';
|
|
4
4
|
export declare const plugin: PluginFunction<ReactApolloRawPluginConfig, Types.ComplexPluginOutput>;
|
|
5
5
|
export declare const validate: PluginValidateFn<any>;
|
|
6
6
|
export { ReactApolloVisitor };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ClientSideBaseVisitor, ClientSideBasePluginConfig, LoadedFragment } from '@graphql-codegen/visitor-plugin-common';
|
|
2
|
-
import { ReactApolloRawPluginConfig } from './config';
|
|
2
|
+
import { ReactApolloRawPluginConfig } from './config.js';
|
|
3
3
|
import { OperationDefinitionNode, GraphQLSchema } from 'graphql';
|
|
4
4
|
import { Types } from '@graphql-codegen/plugin-helpers';
|
|
5
5
|
export interface ReactApolloPluginConfig extends ClientSideBasePluginConfig {
|