@graphql-codegen/typescript-react-offix 2.2.14 → 2.3.0-alpha-29eb1293b.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/index.js ADDED
@@ -0,0 +1,33 @@
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: [...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 ((0, path_1.extname)(outputFile) !== '.tsx' && (0, path_1.extname)(outputFile) !== '.ts') {
30
+ throw new Error(`Plugin "react-apollo" requires extension to be ".tsx" or ".ts!`);
31
+ }
32
+ };
33
+ exports.validate = validate;
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
@@ -1,29 +1,23 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
-
7
- const pluginHelpers = require('@graphql-codegen/plugin-helpers');
8
- const graphql = require('graphql');
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
-
14
- class ReactApolloVisitor extends visitorPluginCommon.ClientSideBaseVisitor {
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 change_case_all_1 = require("change-case-all");
8
+ class ReactApolloVisitor extends visitor_plugin_common_1.ClientSideBaseVisitor {
15
9
  constructor(schema, fragments, rawConfig, documents) {
16
10
  super(schema, fragments, rawConfig, {});
17
11
  this.imports = new Set();
18
12
  this._externalImportPrefix = this.config.importOperationTypesFrom ? `${this.config.importOperationTypesFrom}.` : '';
19
13
  this._documents = documents;
20
- autoBind(this);
14
+ (0, auto_bind_1.default)(this);
21
15
  }
22
16
  getOffixReactHooksImport() {
23
17
  return `import * as OffixReactHooks from "react-offix-hooks";`;
24
18
  }
25
19
  getDocumentNodeVariable(node, documentVariableName) {
26
- return this.config.documentMode === visitorPluginCommon.DocumentMode.external ? `Operations.${node.name.value}` : documentVariableName;
20
+ return this.config.documentMode === visitor_plugin_common_1.DocumentMode.external ? `Operations.${node.name.value}` : documentVariableName;
27
21
  }
28
22
  getImports() {
29
23
  const baseImports = super.getImports({ excludeFragments: true });
@@ -63,7 +57,7 @@ class ReactApolloVisitor extends visitorPluginCommon.ClientSideBaseVisitor {
63
57
  prefix: this.config.documentVariablePrefix,
64
58
  useTypesPrefix: false,
65
59
  });
66
- const operationType = changeCaseAll.pascalCase(node.operation);
60
+ const operationType = (0, change_case_all_1.pascalCase)(node.operation);
67
61
  const operationTypeSuffix = this.getOperationSuffix(node, operationType);
68
62
  const operationResultType = this.convertName(node, {
69
63
  suffix: operationTypeSuffix + this._parsedConfig.operationResultSuffix,
@@ -75,31 +69,4 @@ class ReactApolloVisitor extends visitorPluginCommon.ClientSideBaseVisitor {
75
69
  return [additional].filter(a => a).join('\n');
76
70
  }
77
71
  }
78
-
79
- const plugin = (schema, documents, config) => {
80
- const allAst = graphql.concatAST(documents.map(v => v.document));
81
- const allFragments = [
82
- ...allAst.definitions.filter(d => d.kind === graphql.Kind.FRAGMENT_DEFINITION).map(fragmentDef => ({
83
- node: fragmentDef,
84
- name: fragmentDef.name.value,
85
- onType: fragmentDef.typeCondition.name.value,
86
- isExternal: false,
87
- })),
88
- ...(config.externalFragments || []),
89
- ];
90
- const visitor = new ReactApolloVisitor(schema, allFragments, config, documents);
91
- const visitorResult = pluginHelpers.oldVisit(allAst, { leave: visitor });
92
- return {
93
- prepend: visitor.getImports(),
94
- content: [...visitorResult.definitions.filter(t => typeof t === 'string')].join('\n'),
95
- };
96
- };
97
- const validate = async (_schema, _documents, _config, outputFile) => {
98
- if (path.extname(outputFile) !== '.tsx' && path.extname(outputFile) !== '.ts') {
99
- throw new Error(`Plugin "react-apollo" requires extension to be ".tsx" or ".ts!`);
100
- }
101
- };
102
-
103
72
  exports.ReactApolloVisitor = ReactApolloVisitor;
104
- exports.plugin = plugin;
105
- exports.validate = validate;
package/esm/index.js ADDED
@@ -0,0 +1,28 @@
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: [...visitorResult.definitions.filter(t => typeof t === 'string')].join('\n'),
21
+ };
22
+ };
23
+ export const validate = async (_schema, _documents, _config, outputFile) => {
24
+ if (extname(outputFile) !== '.tsx' && extname(outputFile) !== '.ts') {
25
+ throw new Error(`Plugin "react-apollo" requires extension to be ".tsx" or ".ts!`);
26
+ }
27
+ };
28
+ export { ReactApolloVisitor };
@@ -1,11 +1,7 @@
1
- import { oldVisit } from '@graphql-codegen/plugin-helpers';
2
- import { concatAST, Kind } from 'graphql';
3
- import { ClientSideBaseVisitor, DocumentMode } from '@graphql-codegen/visitor-plugin-common';
1
+ import { ClientSideBaseVisitor, DocumentMode, } from '@graphql-codegen/visitor-plugin-common';
4
2
  import autoBind from 'auto-bind';
5
3
  import { pascalCase } from 'change-case-all';
6
- import { extname } from 'path';
7
-
8
- class ReactApolloVisitor extends ClientSideBaseVisitor {
4
+ export class ReactApolloVisitor extends ClientSideBaseVisitor {
9
5
  constructor(schema, fragments, rawConfig, documents) {
10
6
  super(schema, fragments, rawConfig, {});
11
7
  this.imports = new Set();
@@ -69,29 +65,3 @@ class ReactApolloVisitor extends ClientSideBaseVisitor {
69
65
  return [additional].filter(a => a).join('\n');
70
66
  }
71
67
  }
72
-
73
- const plugin = (schema, documents, config) => {
74
- const allAst = concatAST(documents.map(v => v.document));
75
- const allFragments = [
76
- ...allAst.definitions.filter(d => d.kind === Kind.FRAGMENT_DEFINITION).map(fragmentDef => ({
77
- node: fragmentDef,
78
- name: fragmentDef.name.value,
79
- onType: fragmentDef.typeCondition.name.value,
80
- isExternal: false,
81
- })),
82
- ...(config.externalFragments || []),
83
- ];
84
- const visitor = new ReactApolloVisitor(schema, allFragments, config, documents);
85
- const visitorResult = oldVisit(allAst, { leave: visitor });
86
- return {
87
- prepend: visitor.getImports(),
88
- content: [...visitorResult.definitions.filter(t => typeof t === 'string')].join('\n'),
89
- };
90
- };
91
- const validate = async (_schema, _documents, _config, outputFile) => {
92
- if (extname(outputFile) !== '.tsx' && extname(outputFile) !== '.ts') {
93
- throw new Error(`Plugin "react-apollo" requires extension to be ".tsx" or ".ts!`);
94
- }
95
- };
96
-
97
- export { ReactApolloVisitor, plugin, validate };
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@graphql-codegen/typescript-react-offix",
3
- "version": "2.2.14",
3
+ "version": "2.3.0-alpha-29eb1293b.0",
4
4
  "description": "GraphQL Code Generator plugin for generating useOffline mutations for offix use",
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.4.0",
11
- "@graphql-codegen/visitor-plugin-common": "2.10.0",
10
+ "@graphql-codegen/plugin-helpers": "^2.5.0-alpha-29eb1293b.0",
11
+ "@graphql-codegen/visitor-plugin-common": "2.11.0-alpha-29eb1293b.0",
12
12
  "auto-bind": "~4.0.0",
13
13
  "change-case-all": "1.0.14"
14
14
  },
@@ -18,21 +18,28 @@
18
18
  "directory": "packages/plugins/typescript/react-apollo-offix"
19
19
  },
20
20
  "license": "MIT",
21
- "main": "index.js",
22
- "module": "index.mjs",
23
- "typings": "index.d.ts",
21
+ "main": "cjs/index.js",
22
+ "module": "esm/index.js",
23
+ "typings": "typings/index.d.ts",
24
24
  "typescript": {
25
- "definition": "index.d.ts"
25
+ "definition": "typings/index.d.ts"
26
26
  },
27
+ "type": "module",
27
28
  "exports": {
28
- "./package.json": "./package.json",
29
29
  ".": {
30
- "require": "./index.js",
31
- "import": "./index.mjs"
30
+ "require": {
31
+ "types": "./typings/index.d.ts",
32
+ "default": "./cjs/index.js"
33
+ },
34
+ "import": {
35
+ "types": "./typings/index.d.ts",
36
+ "default": "./esm/index.js"
37
+ },
38
+ "default": {
39
+ "types": "./typings/index.d.ts",
40
+ "default": "./esm/index.js"
41
+ }
32
42
  },
33
- "./*": {
34
- "require": "./*.js",
35
- "import": "./*.mjs"
36
- }
43
+ "./package.json": "./package.json"
37
44
  }
38
- }
45
+ }
@@ -1,6 +1,6 @@
1
1
  import { PluginValidateFn, PluginFunction } from '@graphql-codegen/plugin-helpers';
2
2
  import { RawClientSideBasePluginConfig } from '@graphql-codegen/visitor-plugin-common';
3
- import { ReactApolloVisitor } from './visitor';
3
+ import { ReactApolloVisitor } from './visitor.js';
4
4
  export declare const plugin: PluginFunction<RawClientSideBasePluginConfig>;
5
5
  export declare const validate: PluginValidateFn<any>;
6
6
  export { ReactApolloVisitor };
File without changes