@graphql-codegen/java 3.2.14-alpha-7a65ba05d.0 → 3.2.16-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 ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/cjs/index.js ADDED
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.plugin = void 0;
4
+ const plugin_helpers_1 = require("@graphql-codegen/plugin-helpers");
5
+ const visitor_js_1 = require("./visitor.js");
6
+ const java_common_1 = require("@graphql-codegen/java-common");
7
+ const path_1 = require("path");
8
+ const plugin = async (schema, documents, config, { outputFile }) => {
9
+ const relevantPath = (0, path_1.dirname)((0, path_1.normalize)(outputFile));
10
+ const defaultPackageName = (0, java_common_1.buildPackageNameFromPath)(relevantPath);
11
+ const visitor = new visitor_js_1.JavaResolversVisitor(config, schema, defaultPackageName);
12
+ const astNode = (0, plugin_helpers_1.getCachedDocumentNodeFromSchema)(schema);
13
+ const visitorResult = (0, plugin_helpers_1.oldVisit)(astNode, { leave: visitor });
14
+ const imports = visitor.getImports();
15
+ const packageName = visitor.getPackageName();
16
+ const blockContent = visitorResult.definitions.filter(d => typeof d === 'string').join('\n');
17
+ const wrappedContent = visitor.wrapWithClass(blockContent);
18
+ return [packageName, imports, wrappedContent].join('\n');
19
+ };
20
+ exports.plugin = plugin;
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
@@ -1,14 +1,10 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- const pluginHelpers = require('@graphql-codegen/plugin-helpers');
6
- const visitorPluginCommon = require('@graphql-codegen/visitor-plugin-common');
7
- const graphql = require('graphql');
8
- const javaCommon = require('@graphql-codegen/java-common');
9
- const path = require('path');
10
-
11
- class JavaResolversVisitor extends visitorPluginCommon.BaseVisitor {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.JavaResolversVisitor = void 0;
4
+ const visitor_plugin_common_1 = require("@graphql-codegen/visitor-plugin-common");
5
+ const graphql_1 = require("graphql");
6
+ const java_common_1 = require("@graphql-codegen/java-common");
7
+ class JavaResolversVisitor extends visitor_plugin_common_1.BaseVisitor {
12
8
  constructor(rawConfig, _schema, defaultPackageName) {
13
9
  super(rawConfig, {
14
10
  enumValues: rawConfig.enumValues || {},
@@ -16,7 +12,7 @@ class JavaResolversVisitor extends visitorPluginCommon.BaseVisitor {
16
12
  className: rawConfig.className || 'Types',
17
13
  classMembersPrefix: rawConfig.classMembersPrefix || '',
18
14
  package: rawConfig.package || defaultPackageName,
19
- scalars: visitorPluginCommon.buildScalarsFromConfig(_schema, rawConfig, javaCommon.JAVA_SCALARS, 'Object'),
15
+ scalars: (0, visitor_plugin_common_1.buildScalarsFromConfig)(_schema, rawConfig, java_common_1.JAVA_SCALARS, 'Object'),
20
16
  useEmptyCtor: rawConfig.useEmptyCtor || false,
21
17
  });
22
18
  this._schema = _schema;
@@ -39,11 +35,11 @@ class JavaResolversVisitor extends visitorPluginCommon.BaseVisitor {
39
35
  return allImports.map(i => `import ${i};`).join('\n') + '\n';
40
36
  }
41
37
  wrapWithClass(content) {
42
- return new javaCommon.JavaDeclarationBlock()
38
+ return new java_common_1.JavaDeclarationBlock()
43
39
  .access('public')
44
40
  .asKind('class')
45
41
  .withName(this.config.className)
46
- .withBlock(visitorPluginCommon.indentMultiline(content)).string;
42
+ .withBlock((0, visitor_plugin_common_1.indentMultiline)(content)).string;
47
43
  }
48
44
  getPackageName() {
49
45
  return `package ${this.config.package};\n`;
@@ -58,7 +54,7 @@ class JavaResolversVisitor extends visitorPluginCommon.BaseVisitor {
58
54
  }
59
55
  EnumValueDefinition(node) {
60
56
  return (enumName) => {
61
- return visitorPluginCommon.indent(`${this.getEnumValue(enumName, node.name.value)}`);
57
+ return (0, visitor_plugin_common_1.indent)(`${this.getEnumValue(enumName, node.name.value)}`);
62
58
  };
63
59
  }
64
60
  EnumTypeDefinition(node) {
@@ -75,9 +71,9 @@ class JavaResolversVisitor extends visitorPluginCommon.BaseVisitor {
75
71
  return a;
76
72
  })
77
73
  .join(',\n');
78
- const enumCtor = visitorPluginCommon.indentMultiline(``);
74
+ const enumCtor = (0, visitor_plugin_common_1.indentMultiline)(``);
79
75
  const enumBlock = [enumValues, enumCtor].join('\n');
80
- return new javaCommon.JavaDeclarationBlock()
76
+ return new java_common_1.JavaDeclarationBlock()
81
77
  .access('public')
82
78
  .asKind('enum')
83
79
  .withComment(node.description)
@@ -85,12 +81,12 @@ class JavaResolversVisitor extends visitorPluginCommon.BaseVisitor {
85
81
  .withBlock(enumBlock).string;
86
82
  }
87
83
  resolveInputFieldType(typeNode) {
88
- const innerType = visitorPluginCommon.getBaseTypeNode(typeNode);
84
+ const innerType = (0, visitor_plugin_common_1.getBaseTypeNode)(typeNode);
89
85
  const schemaType = this._schema.getType(innerType.name.value);
90
- const isArray = typeNode.kind === graphql.Kind.LIST_TYPE ||
91
- (typeNode.kind === graphql.Kind.NON_NULL_TYPE && typeNode.type.kind === graphql.Kind.LIST_TYPE);
86
+ const isArray = typeNode.kind === graphql_1.Kind.LIST_TYPE ||
87
+ (typeNode.kind === graphql_1.Kind.NON_NULL_TYPE && typeNode.type.kind === graphql_1.Kind.LIST_TYPE);
92
88
  let result;
93
- if (graphql.isScalarType(schemaType)) {
89
+ if ((0, graphql_1.isScalarType)(schemaType)) {
94
90
  if (this.scalars[schemaType.name]) {
95
91
  result = {
96
92
  baseType: this.scalars[schemaType.name],
@@ -104,7 +100,7 @@ class JavaResolversVisitor extends visitorPluginCommon.BaseVisitor {
104
100
  result = { isArray, baseType: 'Object', typeName: 'Object', isScalar: true, isEnum: false };
105
101
  }
106
102
  }
107
- else if (graphql.isInputObjectType(schemaType)) {
103
+ else if ((0, graphql_1.isInputObjectType)(schemaType)) {
108
104
  const convertedName = this.convertName(schemaType.name);
109
105
  const typeName = convertedName.endsWith('Input') ? convertedName : `${convertedName}Input`;
110
106
  result = {
@@ -115,7 +111,7 @@ class JavaResolversVisitor extends visitorPluginCommon.BaseVisitor {
115
111
  isArray,
116
112
  };
117
113
  }
118
- else if (graphql.isEnumType(schemaType)) {
114
+ else if ((0, graphql_1.isEnumType)(schemaType)) {
119
115
  result = {
120
116
  isArray,
121
117
  baseType: this.convertName(schemaType.name),
@@ -128,7 +124,7 @@ class JavaResolversVisitor extends visitorPluginCommon.BaseVisitor {
128
124
  result = { isArray, baseType: 'Object', typeName: 'Object', isScalar: true, isEnum: false };
129
125
  }
130
126
  if (result) {
131
- result.typeName = javaCommon.wrapTypeWithModifiers(result.typeName, typeNode, this.config.listType);
127
+ result.typeName = (0, java_common_1.wrapTypeWithModifiers)(result.typeName, typeNode, this.config.listType);
132
128
  }
133
129
  return result;
134
130
  }
@@ -139,9 +135,9 @@ class JavaResolversVisitor extends visitorPluginCommon.BaseVisitor {
139
135
  const typeToUse = this.resolveInputFieldType(arg.type);
140
136
  if (arg.name.value === 'interface' || arg.name.value === 'new') {
141
137
  // forcing prefix of _ since interface is a keyword in JAVA
142
- return visitorPluginCommon.indent(`private ${typeToUse.typeName} _${this.config.classMembersPrefix}${arg.name.value};`);
138
+ return (0, visitor_plugin_common_1.indent)(`private ${typeToUse.typeName} _${this.config.classMembersPrefix}${arg.name.value};`);
143
139
  }
144
- return visitorPluginCommon.indent(`private ${typeToUse.typeName} ${this.config.classMembersPrefix}${arg.name.value};`);
140
+ return (0, visitor_plugin_common_1.indent)(`private ${typeToUse.typeName} ${this.config.classMembersPrefix}${arg.name.value};`);
145
141
  })
146
142
  .join('\n');
147
143
  const ctorSet = inputValueArray
@@ -150,22 +146,22 @@ class JavaResolversVisitor extends visitorPluginCommon.BaseVisitor {
150
146
  if (typeToUse.isArray && !typeToUse.isScalar) {
151
147
  this._addListImport = true;
152
148
  if (typeToUse.isEnum) {
153
- return visitorPluginCommon.indentMultiline(`if (args.get("${arg.name.value}") != null) {
149
+ return (0, visitor_plugin_common_1.indentMultiline)(`if (args.get("${arg.name.value}") != null) {
154
150
  this.${this.config.classMembersPrefix}${arg.name.value} = ((List<Object>) args.get("${arg.name.value}")).stream()
155
151
  .map(item -> item instanceof ${typeToUse.baseType} ? item : ${typeToUse.baseType}.valueOf((String) item))
156
152
  .map(${typeToUse.baseType}.class::cast)
157
153
  .collect(Collectors.toList());
158
154
  }`, 3);
159
155
  }
160
- return visitorPluginCommon.indentMultiline(`if (args.get("${arg.name.value}") != null) {
156
+ return (0, visitor_plugin_common_1.indentMultiline)(`if (args.get("${arg.name.value}") != null) {
161
157
  this.${arg.name.value} = (${this.config.listType}<${typeToUse.baseType}>) args.get("${arg.name.value}");
162
158
  }`, 3);
163
159
  }
164
160
  if (typeToUse.isScalar) {
165
- return visitorPluginCommon.indent(`this.${this.config.classMembersPrefix}${arg.name.value} = (${typeToUse.typeName}) args.get("${arg.name.value}");`, 3);
161
+ return (0, visitor_plugin_common_1.indent)(`this.${this.config.classMembersPrefix}${arg.name.value} = (${typeToUse.typeName}) args.get("${arg.name.value}");`, 3);
166
162
  }
167
163
  if (typeToUse.isEnum) {
168
- return visitorPluginCommon.indentMultiline(`if (args.get("${arg.name.value}") instanceof ${typeToUse.typeName}) {
164
+ return (0, visitor_plugin_common_1.indentMultiline)(`if (args.get("${arg.name.value}") instanceof ${typeToUse.typeName}) {
169
165
  this.${this.config.classMembersPrefix}${arg.name.value} = (${typeToUse.typeName}) args.get("${arg.name.value}");
170
166
  } else {
171
167
  this.${this.config.classMembersPrefix}${arg.name.value} = ${typeToUse.typeName}.valueOf((String) args.get("${arg.name.value}"));
@@ -173,9 +169,9 @@ class JavaResolversVisitor extends visitorPluginCommon.BaseVisitor {
173
169
  }
174
170
  if (arg.name.value === 'interface') {
175
171
  // forcing prefix of _ since interface is a keyword in JAVA
176
- return visitorPluginCommon.indent(`this._${this.config.classMembersPrefix}${arg.name.value} = new ${typeToUse.typeName}((Map<String, Object>) args.get("${arg.name.value}"));`, 3);
172
+ return (0, visitor_plugin_common_1.indent)(`this._${this.config.classMembersPrefix}${arg.name.value} = new ${typeToUse.typeName}((Map<String, Object>) args.get("${arg.name.value}"));`, 3);
177
173
  }
178
- return visitorPluginCommon.indent(`this.${this.config.classMembersPrefix}${arg.name.value} = new ${typeToUse.typeName}((Map<String, Object>) args.get("${arg.name.value}"));`, 3);
174
+ return (0, visitor_plugin_common_1.indent)(`this.${this.config.classMembersPrefix}${arg.name.value} = new ${typeToUse.typeName}((Map<String, Object>) args.get("${arg.name.value}"));`, 3);
179
175
  })
180
176
  .join('\n');
181
177
  const getters = inputValueArray
@@ -183,18 +179,18 @@ class JavaResolversVisitor extends visitorPluginCommon.BaseVisitor {
183
179
  const typeToUse = this.resolveInputFieldType(arg.type);
184
180
  if (arg.name.value === 'interface' || arg.name.value === 'new') {
185
181
  // forcing prefix of _ since interface is a keyword in JAVA
186
- return visitorPluginCommon.indent(`public ${typeToUse.typeName} get${this.convertName(arg.name.value)}() { return this._${this.config.classMembersPrefix}${arg.name.value}; }`);
182
+ return (0, visitor_plugin_common_1.indent)(`public ${typeToUse.typeName} get${this.convertName(arg.name.value)}() { return this._${this.config.classMembersPrefix}${arg.name.value}; }`);
187
183
  }
188
- return visitorPluginCommon.indent(`public ${typeToUse.typeName} get${this.convertName(arg.name.value)}() { return this.${this.config.classMembersPrefix}${arg.name.value}; }`);
184
+ return (0, visitor_plugin_common_1.indent)(`public ${typeToUse.typeName} get${this.convertName(arg.name.value)}() { return this.${this.config.classMembersPrefix}${arg.name.value}; }`);
189
185
  })
190
186
  .join('\n');
191
187
  const setters = inputValueArray
192
188
  .map(arg => {
193
189
  const typeToUse = this.resolveInputFieldType(arg.type);
194
190
  if (arg.name.value === 'interface' || arg.name.value === 'new') {
195
- return visitorPluginCommon.indent(`public void set${this.convertName(arg.name.value)}(${typeToUse.typeName} _${arg.name.value}) { this._${arg.name.value} = _${arg.name.value}; }`);
191
+ return (0, visitor_plugin_common_1.indent)(`public void set${this.convertName(arg.name.value)}(${typeToUse.typeName} _${arg.name.value}) { this._${arg.name.value} = _${arg.name.value}; }`);
196
192
  }
197
- return visitorPluginCommon.indent(`public void set${this.convertName(arg.name.value)}(${typeToUse.typeName} ${arg.name.value}) { this.${arg.name.value} = ${arg.name.value}; }`);
193
+ return (0, visitor_plugin_common_1.indent)(`public void set${this.convertName(arg.name.value)}(${typeToUse.typeName} ${arg.name.value}) { this.${arg.name.value} = ${arg.name.value}; }`);
198
194
  })
199
195
  .join('\n');
200
196
  if (this.config.useEmptyCtor) {
@@ -239,18 +235,4 @@ ${setters}
239
235
  return fieldsArguments.join('\n');
240
236
  }
241
237
  }
242
-
243
- const plugin = async (schema, documents, config, { outputFile }) => {
244
- const relevantPath = path.dirname(path.normalize(outputFile));
245
- const defaultPackageName = javaCommon.buildPackageNameFromPath(relevantPath);
246
- const visitor = new JavaResolversVisitor(config, schema, defaultPackageName);
247
- const astNode = pluginHelpers.getCachedDocumentNodeFromSchema(schema);
248
- const visitorResult = pluginHelpers.oldVisit(astNode, { leave: visitor });
249
- const imports = visitor.getImports();
250
- const packageName = visitor.getPackageName();
251
- const blockContent = visitorResult.definitions.filter(d => typeof d === 'string').join('\n');
252
- const wrappedContent = visitor.wrapWithClass(blockContent);
253
- return [packageName, imports, wrappedContent].join('\n');
254
- };
255
-
256
- exports.plugin = plugin;
238
+ exports.JavaResolversVisitor = JavaResolversVisitor;
package/esm/config.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/esm/index.js ADDED
@@ -0,0 +1,16 @@
1
+ import { getCachedDocumentNodeFromSchema, oldVisit } from '@graphql-codegen/plugin-helpers';
2
+ import { JavaResolversVisitor } from './visitor.js';
3
+ import { buildPackageNameFromPath } from '@graphql-codegen/java-common';
4
+ import { dirname, normalize } from 'path';
5
+ export const plugin = async (schema, documents, config, { outputFile }) => {
6
+ const relevantPath = dirname(normalize(outputFile));
7
+ const defaultPackageName = buildPackageNameFromPath(relevantPath);
8
+ const visitor = new JavaResolversVisitor(config, schema, defaultPackageName);
9
+ const astNode = getCachedDocumentNodeFromSchema(schema);
10
+ const visitorResult = oldVisit(astNode, { leave: visitor });
11
+ const imports = visitor.getImports();
12
+ const packageName = visitor.getPackageName();
13
+ const blockContent = visitorResult.definitions.filter(d => typeof d === 'string').join('\n');
14
+ const wrappedContent = visitor.wrapWithClass(blockContent);
15
+ return [packageName, imports, wrappedContent].join('\n');
16
+ };
@@ -1,10 +1,7 @@
1
- import { getCachedDocumentNodeFromSchema, oldVisit } from '@graphql-codegen/plugin-helpers';
2
- import { BaseVisitor, buildScalarsFromConfig, indentMultiline, indent, getBaseTypeNode } from '@graphql-codegen/visitor-plugin-common';
3
- import { Kind, isScalarType, isInputObjectType, isEnumType } from 'graphql';
4
- import { JAVA_SCALARS, JavaDeclarationBlock, wrapTypeWithModifiers, buildPackageNameFromPath } from '@graphql-codegen/java-common';
5
- import { dirname, normalize } from 'path';
6
-
7
- class JavaResolversVisitor extends BaseVisitor {
1
+ import { BaseVisitor, indentMultiline, indent, getBaseTypeNode, buildScalarsFromConfig, } from '@graphql-codegen/visitor-plugin-common';
2
+ import { Kind, isScalarType, isInputObjectType, isEnumType, } from 'graphql';
3
+ import { JAVA_SCALARS, JavaDeclarationBlock, wrapTypeWithModifiers } from '@graphql-codegen/java-common';
4
+ export class JavaResolversVisitor extends BaseVisitor {
8
5
  constructor(rawConfig, _schema, defaultPackageName) {
9
6
  super(rawConfig, {
10
7
  enumValues: rawConfig.enumValues || {},
@@ -235,18 +232,3 @@ ${setters}
235
232
  return fieldsArguments.join('\n');
236
233
  }
237
234
  }
238
-
239
- const plugin = async (schema, documents, config, { outputFile }) => {
240
- const relevantPath = dirname(normalize(outputFile));
241
- const defaultPackageName = buildPackageNameFromPath(relevantPath);
242
- const visitor = new JavaResolversVisitor(config, schema, defaultPackageName);
243
- const astNode = getCachedDocumentNodeFromSchema(schema);
244
- const visitorResult = oldVisit(astNode, { leave: visitor });
245
- const imports = visitor.getImports();
246
- const packageName = visitor.getPackageName();
247
- const blockContent = visitorResult.definitions.filter(d => typeof d === 'string').join('\n');
248
- const wrappedContent = visitor.wrapWithClass(blockContent);
249
- return [packageName, imports, wrappedContent].join('\n');
250
- };
251
-
252
- export { plugin };
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@graphql-codegen/java",
3
- "version": "3.2.14-alpha-7a65ba05d.0",
3
+ "version": "3.2.16-alpha-5d16266dd.0",
4
4
  "description": "GraphQL Code Generator plugin for generating Java code based on a GraphQL schema",
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
  },
8
8
  "dependencies": {
9
- "@graphql-codegen/java-common": "^2.1.20-alpha-7a65ba05d.0",
9
+ "@graphql-codegen/java-common": "^2.1.22-alpha-5d16266dd.0",
10
10
  "@graphql-codegen/plugin-helpers": "^2.4.0",
11
- "@graphql-codegen/visitor-plugin-common": "2.9.1-alpha-7a65ba05d.0",
11
+ "@graphql-codegen/visitor-plugin-common": "2.11.0-alpha-5d16266dd.0",
12
12
  "tslib": "~2.4.0"
13
13
  },
14
14
  "repository": {
@@ -17,21 +17,28 @@
17
17
  "directory": "packages/plugins/java/java"
18
18
  },
19
19
  "license": "MIT",
20
- "main": "index.js",
21
- "module": "index.mjs",
22
- "typings": "index.d.ts",
20
+ "main": "cjs/index.js",
21
+ "module": "esm/index.js",
22
+ "typings": "typings/index.d.ts",
23
23
  "typescript": {
24
- "definition": "index.d.ts"
24
+ "definition": "typings/index.d.ts"
25
25
  },
26
+ "type": "module",
26
27
  "exports": {
27
- "./package.json": "./package.json",
28
28
  ".": {
29
- "require": "./index.js",
30
- "import": "./index.mjs"
29
+ "require": {
30
+ "types": "./typings/index.d.ts",
31
+ "default": "./cjs/index.js"
32
+ },
33
+ "import": {
34
+ "types": "./typings/index.d.ts",
35
+ "default": "./esm/index.js"
36
+ },
37
+ "default": {
38
+ "types": "./typings/index.d.ts",
39
+ "default": "./esm/index.js"
40
+ }
31
41
  },
32
- "./*": {
33
- "require": "./*.js",
34
- "import": "./*.mjs"
35
- }
42
+ "./package.json": "./package.json"
36
43
  }
37
- }
44
+ }
File without changes
@@ -1,3 +1,3 @@
1
1
  import { PluginFunction } from '@graphql-codegen/plugin-helpers';
2
- import { JavaResolversPluginRawConfig } from './config';
2
+ import { JavaResolversPluginRawConfig } from './config.js';
3
3
  export declare const plugin: PluginFunction<JavaResolversPluginRawConfig>;
@@ -1,5 +1,5 @@
1
1
  import { ParsedConfig, BaseVisitor, EnumValuesMap } from '@graphql-codegen/visitor-plugin-common';
2
- import { JavaResolversPluginRawConfig } from './config';
2
+ import { JavaResolversPluginRawConfig } from './config.js';
3
3
  import { GraphQLSchema, EnumTypeDefinitionNode, EnumValueDefinitionNode, InputObjectTypeDefinitionNode, ObjectTypeDefinitionNode, FieldDefinitionNode, InputValueDefinitionNode, TypeNode } from 'graphql';
4
4
  export interface JavaResolverParsedConfig extends ParsedConfig {
5
5
  package: string;