@graphql-codegen/java-apollo-android 2.1.6 → 2.2.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.
Files changed (3) hide show
  1. package/index.js +11 -8
  2. package/index.mjs +12 -9
  3. package/package.json +4 -4
package/index.js CHANGED
@@ -4,10 +4,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
6
 
7
+ const pluginHelpers = require('@graphql-codegen/plugin-helpers');
7
8
  const graphql = require('graphql');
8
9
  const visitorPluginCommon = require('@graphql-codegen/visitor-plugin-common');
9
10
  const javaCommon = require('@graphql-codegen/java-common');
10
- const pluginHelpers = require('@graphql-codegen/plugin-helpers');
11
11
  const crypto = require('crypto');
12
12
  const pluralize = _interopDefault(require('pluralize'));
13
13
  const changeCaseAll = require('change-case-all');
@@ -354,7 +354,7 @@ function visitFieldArguments(selection, imports) {
354
354
  imports.add(Imports.UnmodifiableMapBuilder);
355
355
  imports.add(Imports.String);
356
356
  imports.add(Imports.Object);
357
- return graphql.visit(selection, {
357
+ return pluginHelpers.oldVisit(selection, {
358
358
  leave: {
359
359
  Field: (node) => {
360
360
  return (`new UnmodifiableMapBuilder<String, Object>(${node.arguments.length})` + node.arguments.join('') + '.build()');
@@ -1258,7 +1258,7 @@ const plugin = (schema, documents, config) => {
1258
1258
  if (!visitor) {
1259
1259
  return { content: '' };
1260
1260
  }
1261
- const visitResult = graphql.visit(allAst, visitor);
1261
+ const visitResult = pluginHelpers.oldVisit(allAst, visitor);
1262
1262
  const additionalContent = visitor.additionalContent();
1263
1263
  const imports = visitor.getImports();
1264
1264
  return {
@@ -1275,8 +1275,8 @@ const preset = {
1275
1275
  const outDir = options.baseOutputDir;
1276
1276
  const inputTypesAst = [];
1277
1277
  graphql.visit(options.schema, {
1278
- enter: {
1279
- InputObjectTypeDefinition(node) {
1278
+ InputObjectTypeDefinition: {
1279
+ enter(node) {
1280
1280
  inputTypesAst.push(node);
1281
1281
  },
1282
1282
  },
@@ -1305,6 +1305,7 @@ const preset = {
1305
1305
  documents: [],
1306
1306
  },
1307
1307
  ...inputTypesDocumentNode.definitions.map((ast) => {
1308
+ const document = { kind: graphql.Kind.DOCUMENT, definitions: [ast] };
1308
1309
  return {
1309
1310
  filename: path.join(outDir, packageNameToDirectory(options.config.typePackage), ast.name.value + '.java'),
1310
1311
  plugins: options.plugins,
@@ -1315,13 +1316,14 @@ const preset = {
1315
1316
  skipDocumentsValidation: true,
1316
1317
  },
1317
1318
  schema: options.schema,
1318
- documents: [{ document: { kind: graphql.Kind.DOCUMENT, definitions: [ast] }, location: '' }],
1319
+ documents: [{ document, location: '' }],
1319
1320
  };
1320
1321
  }),
1321
1322
  ...operationsAst.map((ast) => {
1322
1323
  const fileName = ast.name.value.toLowerCase().endsWith(ast.operation)
1323
1324
  ? ast.name.value
1324
1325
  : `${ast.name.value}${changeCaseAll.pascalCase(ast.operation)}`;
1326
+ const document = { kind: graphql.Kind.DOCUMENT, definitions: [ast] };
1325
1327
  return {
1326
1328
  filename: path.join(outDir, packageNameToDirectory(options.config.package), fileName + '.java'),
1327
1329
  plugins: options.plugins,
@@ -1332,10 +1334,11 @@ const preset = {
1332
1334
  externalFragments,
1333
1335
  },
1334
1336
  schema: options.schema,
1335
- documents: [{ document: { kind: graphql.Kind.DOCUMENT, definitions: [ast] }, location: '' }],
1337
+ documents: [{ document, location: '' }],
1336
1338
  };
1337
1339
  }),
1338
1340
  ...fragments.map((ast) => {
1341
+ const document = { kind: graphql.Kind.DOCUMENT, definitions: [ast] };
1339
1342
  return {
1340
1343
  filename: path.join(outDir, packageNameToDirectory(options.config.fragmentPackage), ast.name.value + '.java'),
1341
1344
  plugins: options.plugins,
@@ -1346,7 +1349,7 @@ const preset = {
1346
1349
  externalFragments,
1347
1350
  },
1348
1351
  schema: options.schema,
1349
- documents: [{ document: { kind: graphql.Kind.DOCUMENT, definitions: [ast] }, location: '' }],
1352
+ documents: [{ document, location: '' }],
1350
1353
  };
1351
1354
  }),
1352
1355
  ];
package/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import { GraphQLObjectType, Kind, isNonNullType, isScalarType, isInputObjectType, isListType, isEnumType, visit, print, isObjectType, isInterfaceType, isUnionType, GraphQLString, concatAST } from 'graphql';
1
+ import { getBaseType, oldVisit } from '@graphql-codegen/plugin-helpers';
2
+ import { GraphQLObjectType, Kind, isNonNullType, isScalarType, isInputObjectType, isListType, isEnumType, print, isObjectType, isInterfaceType, isUnionType, GraphQLString, concatAST, visit } from 'graphql';
2
3
  import { BaseVisitor, buildScalars, getBaseTypeNode, indent, indentMultiline } from '@graphql-codegen/visitor-plugin-common';
3
4
  import { JAVA_SCALARS, JavaDeclarationBlock, buildPackageNameFromPath } from '@graphql-codegen/java-common';
4
- import { getBaseType } from '@graphql-codegen/plugin-helpers';
5
5
  import { createHash } from 'crypto';
6
6
  import pluralize from 'pluralize';
7
7
  import { camelCase, pascalCase } from 'change-case-all';
@@ -348,7 +348,7 @@ function visitFieldArguments(selection, imports) {
348
348
  imports.add(Imports.UnmodifiableMapBuilder);
349
349
  imports.add(Imports.String);
350
350
  imports.add(Imports.Object);
351
- return visit(selection, {
351
+ return oldVisit(selection, {
352
352
  leave: {
353
353
  Field: (node) => {
354
354
  return (`new UnmodifiableMapBuilder<String, Object>(${node.arguments.length})` + node.arguments.join('') + '.build()');
@@ -1252,7 +1252,7 @@ const plugin = (schema, documents, config) => {
1252
1252
  if (!visitor) {
1253
1253
  return { content: '' };
1254
1254
  }
1255
- const visitResult = visit(allAst, visitor);
1255
+ const visitResult = oldVisit(allAst, visitor);
1256
1256
  const additionalContent = visitor.additionalContent();
1257
1257
  const imports = visitor.getImports();
1258
1258
  return {
@@ -1269,8 +1269,8 @@ const preset = {
1269
1269
  const outDir = options.baseOutputDir;
1270
1270
  const inputTypesAst = [];
1271
1271
  visit(options.schema, {
1272
- enter: {
1273
- InputObjectTypeDefinition(node) {
1272
+ InputObjectTypeDefinition: {
1273
+ enter(node) {
1274
1274
  inputTypesAst.push(node);
1275
1275
  },
1276
1276
  },
@@ -1299,6 +1299,7 @@ const preset = {
1299
1299
  documents: [],
1300
1300
  },
1301
1301
  ...inputTypesDocumentNode.definitions.map((ast) => {
1302
+ const document = { kind: Kind.DOCUMENT, definitions: [ast] };
1302
1303
  return {
1303
1304
  filename: join(outDir, packageNameToDirectory(options.config.typePackage), ast.name.value + '.java'),
1304
1305
  plugins: options.plugins,
@@ -1309,13 +1310,14 @@ const preset = {
1309
1310
  skipDocumentsValidation: true,
1310
1311
  },
1311
1312
  schema: options.schema,
1312
- documents: [{ document: { kind: Kind.DOCUMENT, definitions: [ast] }, location: '' }],
1313
+ documents: [{ document, location: '' }],
1313
1314
  };
1314
1315
  }),
1315
1316
  ...operationsAst.map((ast) => {
1316
1317
  const fileName = ast.name.value.toLowerCase().endsWith(ast.operation)
1317
1318
  ? ast.name.value
1318
1319
  : `${ast.name.value}${pascalCase(ast.operation)}`;
1320
+ const document = { kind: Kind.DOCUMENT, definitions: [ast] };
1319
1321
  return {
1320
1322
  filename: join(outDir, packageNameToDirectory(options.config.package), fileName + '.java'),
1321
1323
  plugins: options.plugins,
@@ -1326,10 +1328,11 @@ const preset = {
1326
1328
  externalFragments,
1327
1329
  },
1328
1330
  schema: options.schema,
1329
- documents: [{ document: { kind: Kind.DOCUMENT, definitions: [ast] }, location: '' }],
1331
+ documents: [{ document, location: '' }],
1330
1332
  };
1331
1333
  }),
1332
1334
  ...fragments.map((ast) => {
1335
+ const document = { kind: Kind.DOCUMENT, definitions: [ast] };
1333
1336
  return {
1334
1337
  filename: join(outDir, packageNameToDirectory(options.config.fragmentPackage), ast.name.value + '.java'),
1335
1338
  plugins: options.plugins,
@@ -1340,7 +1343,7 @@ const preset = {
1340
1343
  externalFragments,
1341
1344
  },
1342
1345
  schema: options.schema,
1343
- documents: [{ document: { kind: Kind.DOCUMENT, definitions: [ast] }, location: '' }],
1346
+ documents: [{ document, location: '' }],
1344
1347
  };
1345
1348
  }),
1346
1349
  ];
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@graphql-codegen/java-apollo-android",
3
- "version": "2.1.6",
3
+ "version": "2.2.0",
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"
7
7
  },
8
8
  "dependencies": {
9
- "@graphql-codegen/java-common": "^2.1.6",
10
- "@graphql-codegen/plugin-helpers": "^2.2.0",
11
- "@graphql-codegen/visitor-plugin-common": "2.4.0",
9
+ "@graphql-codegen/java-common": "^2.1.7",
10
+ "@graphql-codegen/plugin-helpers": "^2.3.0",
11
+ "@graphql-codegen/visitor-plugin-common": "2.5.0",
12
12
  "auto-bind": "~4.0.0",
13
13
  "change-case-all": "1.0.14",
14
14
  "pluralize": "^8.0.0",