@graphql-codegen/typescript-graphql-apollo 1.1.2-alpha-3f97058d3.0 → 1.1.2-alpha-2cc8b095b.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 ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/cjs/index.js ADDED
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GraphQLApolloVisitor = 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, "GraphQLApolloVisitor", { enumerable: true, get: function () { return visitor_js_1.GraphQLApolloVisitor; } });
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.GraphQLApolloVisitor(schema, allFragments, config);
21
+ const visitorResult = (0, plugin_helpers_1.oldVisit)(allAst, { leave: visitor });
22
+ return {
23
+ prepend: visitor.getImports(),
24
+ content: [
25
+ visitor.fragments,
26
+ ...visitorResult.definitions.filter(t => typeof t === 'string'),
27
+ visitor.sdkContent,
28
+ ].join('\n'),
29
+ };
30
+ };
31
+ exports.plugin = plugin;
32
+ const validate = async (schema, documents, config, outputFile) => {
33
+ if ((0, path_1.extname)(outputFile) !== '.ts' && (0, path_1.extname)(outputFile) !== 'tsx') {
34
+ throw new Error(`Plugin "typescript-graphql-apollo" requires extension to be ".ts" or ".tsx"!`);
35
+ }
36
+ };
37
+ exports.validate = validate;
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
@@ -1,21 +1,16 @@
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 GraphQLApolloVisitor extends visitorPluginCommon.ClientSideBaseVisitor {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GraphQLApolloVisitor = 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
+ const graphql_1 = require("graphql");
9
+ class GraphQLApolloVisitor extends visitor_plugin_common_1.ClientSideBaseVisitor {
15
10
  constructor(schema, fragments, rawConfig) {
16
11
  super(schema, fragments, rawConfig, {});
17
12
  this._operationsToInclude = [];
18
- autoBind(this);
13
+ (0, auto_bind_1.default)(this);
19
14
  const typeImport = this.config.useTypeImports ? 'import type' : 'import';
20
15
  this._additionalImports.push(`${typeImport} { ApolloClient, QueryOptions, SubscriptionOptions, MutationOptions } from '@apollo/client';`);
21
16
  }
@@ -24,7 +19,7 @@ class GraphQLApolloVisitor extends visitorPluginCommon.ClientSideBaseVisitor {
24
19
  const operationName = (_a = node.name) === null || _a === void 0 ? void 0 : _a.value;
25
20
  if (!operationName) {
26
21
  // eslint-disable-next-line no-console
27
- console.warn(`Anonymous GraphQL operation was ignored in "typescript-graphql-request", please make sure to name your operation: `, graphql.print(node));
22
+ console.warn(`Anonymous GraphQL operation was ignored in "typescript-graphql-request", please make sure to name your operation: `, (0, graphql_1.print)(node));
28
23
  return null;
29
24
  }
30
25
  return super.OperationDefinition(node);
@@ -47,7 +42,7 @@ class GraphQLApolloVisitor extends visitorPluginCommon.ClientSideBaseVisitor {
47
42
  const operationName = x.node.name.value;
48
43
  const genericParameter = x.operationType !== 'Mutation' ? [...generics].reverse() : [...generics];
49
44
  // the reason we're reversing: https://github.com/apollographql/apollo-client/issues/8537
50
- return `${changeCaseAll.camelCase(operationName)}${x.operationType}(options: Partial<${optionType}<${genericParameter.join(', ')}>>) {
45
+ return `${(0, change_case_all_1.camelCase)(operationName)}${x.operationType}(options: Partial<${optionType}<${genericParameter.join(', ')}>>) {
51
46
  return client.${GraphQLApolloVisitor.getApolloOperation(x.operationType)}<${generics.join(', ')}>({...options, ${GraphQLApolloVisitor.getDocumentFieldName(x.operationType)}: ${documentVariableName}})
52
47
  }`;
53
48
  });
@@ -94,35 +89,4 @@ class GraphQLApolloVisitor extends visitorPluginCommon.ClientSideBaseVisitor {
94
89
  }
95
90
  }
96
91
  }
97
-
98
- const plugin = (schema, documents, config) => {
99
- const allAst = graphql.concatAST(documents.map(v => v.document));
100
- const allFragments = [
101
- ...allAst.definitions.filter(d => d.kind === graphql.Kind.FRAGMENT_DEFINITION).map(fragmentDef => ({
102
- node: fragmentDef,
103
- name: fragmentDef.name.value,
104
- onType: fragmentDef.typeCondition.name.value,
105
- isExternal: false,
106
- })),
107
- ...(config.externalFragments || []),
108
- ];
109
- const visitor = new GraphQLApolloVisitor(schema, allFragments, config);
110
- const visitorResult = pluginHelpers.oldVisit(allAst, { leave: visitor });
111
- return {
112
- prepend: visitor.getImports(),
113
- content: [
114
- visitor.fragments,
115
- ...visitorResult.definitions.filter(t => typeof t === 'string'),
116
- visitor.sdkContent,
117
- ].join('\n'),
118
- };
119
- };
120
- const validate = async (schema, documents, config, outputFile) => {
121
- if (path.extname(outputFile) !== '.ts' && path.extname(outputFile) !== 'tsx') {
122
- throw new Error(`Plugin "typescript-graphql-apollo" requires extension to be ".ts" or ".tsx"!`);
123
- }
124
- };
125
-
126
92
  exports.GraphQLApolloVisitor = GraphQLApolloVisitor;
127
- exports.plugin = plugin;
128
- exports.validate = validate;
package/esm/config.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/esm/index.js ADDED
@@ -0,0 +1,32 @@
1
+ import { oldVisit } from '@graphql-codegen/plugin-helpers';
2
+ import { concatAST, Kind } from 'graphql';
3
+ import { GraphQLApolloVisitor } 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 GraphQLApolloVisitor(schema, allFragments, config);
17
+ const visitorResult = oldVisit(allAst, { leave: visitor });
18
+ return {
19
+ prepend: visitor.getImports(),
20
+ content: [
21
+ visitor.fragments,
22
+ ...visitorResult.definitions.filter(t => typeof t === 'string'),
23
+ visitor.sdkContent,
24
+ ].join('\n'),
25
+ };
26
+ };
27
+ export const validate = async (schema, documents, config, outputFile) => {
28
+ if (extname(outputFile) !== '.ts' && extname(outputFile) !== 'tsx') {
29
+ throw new Error(`Plugin "typescript-graphql-apollo" requires extension to be ".ts" or ".tsx"!`);
30
+ }
31
+ };
32
+ export { GraphQLApolloVisitor };
@@ -1,11 +1,8 @@
1
- import { oldVisit } from '@graphql-codegen/plugin-helpers';
2
- import { print, concatAST, Kind } from 'graphql';
3
- import { ClientSideBaseVisitor } from '@graphql-codegen/visitor-plugin-common';
1
+ import { ClientSideBaseVisitor, } from '@graphql-codegen/visitor-plugin-common';
4
2
  import autoBind from 'auto-bind';
5
3
  import { camelCase } from 'change-case-all';
6
- import { extname } from 'path';
7
-
8
- class GraphQLApolloVisitor extends ClientSideBaseVisitor {
4
+ import { print } from 'graphql';
5
+ export class GraphQLApolloVisitor extends ClientSideBaseVisitor {
9
6
  constructor(schema, fragments, rawConfig) {
10
7
  super(schema, fragments, rawConfig, {});
11
8
  this._operationsToInclude = [];
@@ -88,33 +85,3 @@ class GraphQLApolloVisitor extends ClientSideBaseVisitor {
88
85
  }
89
86
  }
90
87
  }
91
-
92
- const plugin = (schema, documents, config) => {
93
- const allAst = concatAST(documents.map(v => v.document));
94
- const allFragments = [
95
- ...allAst.definitions.filter(d => d.kind === Kind.FRAGMENT_DEFINITION).map(fragmentDef => ({
96
- node: fragmentDef,
97
- name: fragmentDef.name.value,
98
- onType: fragmentDef.typeCondition.name.value,
99
- isExternal: false,
100
- })),
101
- ...(config.externalFragments || []),
102
- ];
103
- const visitor = new GraphQLApolloVisitor(schema, allFragments, config);
104
- const visitorResult = oldVisit(allAst, { leave: visitor });
105
- return {
106
- prepend: visitor.getImports(),
107
- content: [
108
- visitor.fragments,
109
- ...visitorResult.definitions.filter(t => typeof t === 'string'),
110
- visitor.sdkContent,
111
- ].join('\n'),
112
- };
113
- };
114
- const validate = async (schema, documents, config, outputFile) => {
115
- if (extname(outputFile) !== '.ts' && extname(outputFile) !== 'tsx') {
116
- throw new Error(`Plugin "typescript-graphql-apollo" requires extension to be ".ts" or ".tsx"!`);
117
- }
118
- };
119
-
120
- export { GraphQLApolloVisitor, plugin, validate };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-codegen/typescript-graphql-apollo",
3
- "version": "1.1.2-alpha-3f97058d3.0",
3
+ "version": "1.1.2-alpha-2cc8b095b.0",
4
4
  "description": "GraphQL Code Generator plugin for generating a ready-to-use SDK based on apollo client and 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.3.2",
11
- "@graphql-codegen/visitor-plugin-common": "^2.9.0-alpha-3f97058d3.0",
11
+ "@graphql-codegen/visitor-plugin-common": "^2.11.0-alpha-2cc8b095b.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/graphql-apollo"
20
20
  },
21
21
  "license": "MIT",
22
- "main": "index.js",
23
- "module": "index.mjs",
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": "./index.js",
32
- "import": "./index.mjs"
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 { PluginValidateFn, PluginFunction } from '@graphql-codegen/plugin-helpers';
2
- import { GraphQLApolloVisitor } from './visitor';
3
- import { RawGraphQLApolloPluginConfig } from './config';
2
+ import { GraphQLApolloVisitor } from './visitor.js';
3
+ import { RawGraphQLApolloPluginConfig } from './config.js';
4
4
  export declare const plugin: PluginFunction<RawGraphQLApolloPluginConfig>;
5
5
  export declare const validate: PluginValidateFn<any>;
6
6
  export { GraphQLApolloVisitor };
@@ -1,6 +1,6 @@
1
1
  import { ClientSideBasePluginConfig, ClientSideBaseVisitor, LoadedFragment } from '@graphql-codegen/visitor-plugin-common';
2
2
  import { GraphQLSchema, OperationDefinitionNode } from 'graphql';
3
- import { RawGraphQLApolloPluginConfig } from './config';
3
+ import { RawGraphQLApolloPluginConfig } from './config.js';
4
4
  export interface GraphQLRequestPluginConfig extends ClientSideBasePluginConfig {
5
5
  rawRequest: boolean;
6
6
  }