@graphql-codegen/java-apollo-android 2.2.6 → 2.2.9

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/index.js CHANGED
@@ -223,16 +223,14 @@ class InputTypeVisitor extends BaseJavaVisitor {
223
223
  this._imports.add(Imports.Nonnull);
224
224
  return `@Nonnull ${typeToUse} ${name}`;
225
225
  }
226
+ else if (wrapWith) {
227
+ return typeof wrapWith === 'function' ? `${wrapWith(typeToUse)} ${name}` : `${wrapWith}<${typeToUse}> ${name}`;
228
+ }
226
229
  else {
227
- if (wrapWith) {
228
- return typeof wrapWith === 'function' ? `${wrapWith(typeToUse)} ${name}` : `${wrapWith}<${typeToUse}> ${name}`;
229
- }
230
- else {
231
- if (applyNullable) {
232
- this._imports.add(Imports.Nullable);
233
- }
234
- return `${applyNullable ? '@Nullable ' : ''}${typeToUse} ${name}`;
230
+ if (applyNullable) {
231
+ this._imports.add(Imports.Nullable);
235
232
  }
233
+ return `${applyNullable ? '@Nullable ' : ''}${typeToUse} ${name}`;
236
234
  }
237
235
  }
238
236
  buildFieldsMarshaller(field) {
@@ -378,7 +376,6 @@ function visitFieldArguments(selection, imports) {
378
376
  });
379
377
  }
380
378
 
381
- const { singular, isPlural } = pluralize;
382
379
  class OperationVisitor extends BaseJavaVisitor {
383
380
  constructor(_schema, rawConfig, _availableFragments) {
384
381
  super(_schema, rawConfig, {
@@ -442,7 +439,7 @@ class OperationVisitor extends BaseJavaVisitor {
442
439
  }
443
440
  createUniqueClassName(inUse, name, count = 0) {
444
441
  const possibleNewName = count === 0 ? name : `${name}${count}`;
445
- while (inUse.includes(possibleNewName)) {
442
+ if (inUse.includes(possibleNewName)) {
446
443
  return this.createUniqueClassName(inUse, name, count + 1);
447
444
  }
448
445
  return possibleNewName;
@@ -482,8 +479,8 @@ class OperationVisitor extends BaseJavaVisitor {
482
479
  const isList = graphql.isListType(field.type) || (graphql.isNonNullType(field.type) && graphql.isListType(field.type.ofType));
483
480
  if (isObject) {
484
481
  let childClsName = this.convertName(field.name);
485
- if (isList && isPlural(childClsName)) {
486
- childClsName = singular(childClsName);
482
+ if (isList && pluralize.isPlural(childClsName)) {
483
+ childClsName = pluralize.singular(childClsName);
487
484
  }
488
485
  this.transformSelectionSet({
489
486
  className: childClsName,
@@ -509,7 +506,7 @@ class OperationVisitor extends BaseJavaVisitor {
509
506
  rawType: field.type,
510
507
  isObject: false,
511
508
  isFragment: false,
512
- isList: isList,
509
+ isList,
513
510
  type: baseType,
514
511
  isNonNull,
515
512
  annotation: fieldAnnotation,
@@ -968,12 +965,12 @@ ${visitorPluginCommon.indentMultiline(inner, 2)}
968
965
  this._imports.add(Imports.Generated);
969
966
  this._imports.add(Imports.ResponseFieldMapper);
970
967
  const dataClasses = this.transformSelectionSet({
971
- className: className,
968
+ className,
972
969
  nonStaticClass: true,
973
970
  implements: ['GraphqlFragment'],
974
971
  selectionSet: node.selectionSet && node.selectionSet.selections ? node.selectionSet.selections : [],
975
972
  result: {},
976
- schemaType: schemaType,
973
+ schemaType,
977
974
  }, false);
978
975
  const rootCls = dataClasses[className];
979
976
  const printed = this.printDocument(node);
package/index.mjs CHANGED
@@ -217,16 +217,14 @@ class InputTypeVisitor extends BaseJavaVisitor {
217
217
  this._imports.add(Imports.Nonnull);
218
218
  return `@Nonnull ${typeToUse} ${name}`;
219
219
  }
220
+ else if (wrapWith) {
221
+ return typeof wrapWith === 'function' ? `${wrapWith(typeToUse)} ${name}` : `${wrapWith}<${typeToUse}> ${name}`;
222
+ }
220
223
  else {
221
- if (wrapWith) {
222
- return typeof wrapWith === 'function' ? `${wrapWith(typeToUse)} ${name}` : `${wrapWith}<${typeToUse}> ${name}`;
223
- }
224
- else {
225
- if (applyNullable) {
226
- this._imports.add(Imports.Nullable);
227
- }
228
- return `${applyNullable ? '@Nullable ' : ''}${typeToUse} ${name}`;
224
+ if (applyNullable) {
225
+ this._imports.add(Imports.Nullable);
229
226
  }
227
+ return `${applyNullable ? '@Nullable ' : ''}${typeToUse} ${name}`;
230
228
  }
231
229
  }
232
230
  buildFieldsMarshaller(field) {
@@ -372,7 +370,6 @@ function visitFieldArguments(selection, imports) {
372
370
  });
373
371
  }
374
372
 
375
- const { singular, isPlural } = pluralize;
376
373
  class OperationVisitor extends BaseJavaVisitor {
377
374
  constructor(_schema, rawConfig, _availableFragments) {
378
375
  super(_schema, rawConfig, {
@@ -436,7 +433,7 @@ class OperationVisitor extends BaseJavaVisitor {
436
433
  }
437
434
  createUniqueClassName(inUse, name, count = 0) {
438
435
  const possibleNewName = count === 0 ? name : `${name}${count}`;
439
- while (inUse.includes(possibleNewName)) {
436
+ if (inUse.includes(possibleNewName)) {
440
437
  return this.createUniqueClassName(inUse, name, count + 1);
441
438
  }
442
439
  return possibleNewName;
@@ -476,8 +473,8 @@ class OperationVisitor extends BaseJavaVisitor {
476
473
  const isList = isListType(field.type) || (isNonNullType(field.type) && isListType(field.type.ofType));
477
474
  if (isObject) {
478
475
  let childClsName = this.convertName(field.name);
479
- if (isList && isPlural(childClsName)) {
480
- childClsName = singular(childClsName);
476
+ if (isList && pluralize.isPlural(childClsName)) {
477
+ childClsName = pluralize.singular(childClsName);
481
478
  }
482
479
  this.transformSelectionSet({
483
480
  className: childClsName,
@@ -503,7 +500,7 @@ class OperationVisitor extends BaseJavaVisitor {
503
500
  rawType: field.type,
504
501
  isObject: false,
505
502
  isFragment: false,
506
- isList: isList,
503
+ isList,
507
504
  type: baseType,
508
505
  isNonNull,
509
506
  annotation: fieldAnnotation,
@@ -962,12 +959,12 @@ ${indentMultiline(inner, 2)}
962
959
  this._imports.add(Imports.Generated);
963
960
  this._imports.add(Imports.ResponseFieldMapper);
964
961
  const dataClasses = this.transformSelectionSet({
965
- className: className,
962
+ className,
966
963
  nonStaticClass: true,
967
964
  implements: ['GraphqlFragment'],
968
965
  selectionSet: node.selectionSet && node.selectionSet.selections ? node.selectionSet.selections : [],
969
966
  result: {},
970
- schemaType: schemaType,
967
+ schemaType,
971
968
  }, false);
972
969
  const rootCls = dataClasses[className];
973
970
  const printed = this.printDocument(node);
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@graphql-codegen/java-apollo-android",
3
- "version": "2.2.6",
3
+ "version": "2.2.9",
4
4
  "description": "GraphQL Code Generator plugin for generating Java classes for Apollo-Android",
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.13",
9
+ "@graphql-codegen/java-common": "^2.1.16",
10
10
  "@graphql-codegen/plugin-helpers": "^2.4.0",
11
- "@graphql-codegen/visitor-plugin-common": "2.7.2",
11
+ "@graphql-codegen/visitor-plugin-common": "2.7.5",
12
12
  "auto-bind": "~4.0.0",
13
13
  "change-case-all": "1.0.14",
14
14
  "pluralize": "^8.0.0",
15
- "tslib": "~2.3.0"
15
+ "tslib": "~2.4.0"
16
16
  },
17
17
  "repository": {
18
18
  "type": "git",
package/plugin.d.ts CHANGED
@@ -9,7 +9,7 @@ export interface JavaApolloAndroidPluginConfig extends RawConfig {
9
9
  * @description Customize the Java package name for the generated operations. The default package name will be generated according to the output file path.
10
10
  *
11
11
  * @exampleMarkdown
12
- * ```yml
12
+ * ```yaml
13
13
  * generates:
14
14
  * ./app/src/main/java/:
15
15
  * preset: java-apollo-android
@@ -24,7 +24,7 @@ export interface JavaApolloAndroidPluginConfig extends RawConfig {
24
24
  * @description Customize the Java package name for the types generated based on input types.
25
25
  *
26
26
  * @exampleMarkdown
27
- * ```yml
27
+ * ```yaml
28
28
  * generates:
29
29
  * ./app/src/main/java/:
30
30
  * preset: java-apollo-android
@@ -39,7 +39,7 @@ export interface JavaApolloAndroidPluginConfig extends RawConfig {
39
39
  * @description Customize the Java package name for the fragments generated classes.
40
40
  *
41
41
  * @exampleMarkdown
42
- * ```yml
42
+ * ```yaml
43
43
  * generates:
44
44
  * ./app/src/main/java/:
45
45
  * preset: java-apollo-android