@graphql-codegen/java-resolvers 2.2.13 → 2.2.15-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,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 mappersImports = 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, mappersImports, wrappedContent].join('\n');
19
+ };
20
+ exports.plugin = plugin;
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
@@ -1,21 +1,17 @@
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 javaCommon = require('@graphql-codegen/java-common');
8
- const path = require('path');
9
-
10
- 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 java_common_1 = require("@graphql-codegen/java-common");
6
+ class JavaResolversVisitor extends visitor_plugin_common_1.BaseVisitor {
11
7
  constructor(rawConfig, _schema, defaultPackageName) {
12
8
  super(rawConfig, {
13
- mappers: visitorPluginCommon.transformMappers(rawConfig.mappers || {}),
9
+ mappers: (0, visitor_plugin_common_1.transformMappers)(rawConfig.mappers || {}),
14
10
  package: rawConfig.package || defaultPackageName,
15
- defaultMapper: visitorPluginCommon.parseMapper(rawConfig.defaultMapper || 'Object'),
11
+ defaultMapper: (0, visitor_plugin_common_1.parseMapper)(rawConfig.defaultMapper || 'Object'),
16
12
  className: rawConfig.className || 'Resolvers',
17
13
  listType: rawConfig.listType || 'Iterable',
18
- scalars: visitorPluginCommon.buildScalarsFromConfig(_schema, rawConfig, javaCommon.JAVA_SCALARS, 'Object'),
14
+ scalars: (0, visitor_plugin_common_1.buildScalarsFromConfig)(_schema, rawConfig, java_common_1.JAVA_SCALARS, 'Object'),
19
15
  });
20
16
  this._includeTypeResolverImport = false;
21
17
  }
@@ -47,15 +43,15 @@ class JavaResolversVisitor extends visitorPluginCommon.BaseVisitor {
47
43
  return `package ${this.config.package};\n`;
48
44
  }
49
45
  wrapWithClass(content) {
50
- return new javaCommon.JavaDeclarationBlock()
46
+ return new java_common_1.JavaDeclarationBlock()
51
47
  .access('public')
52
48
  .asKind('class')
53
49
  .withName(this.config.className)
54
- .withBlock(visitorPluginCommon.indentMultiline(content)).string;
50
+ .withBlock((0, visitor_plugin_common_1.indentMultiline)(content)).string;
55
51
  }
56
52
  UnionTypeDefinition(node) {
57
53
  this._includeTypeResolverImport = true;
58
- return new javaCommon.JavaDeclarationBlock()
54
+ return new java_common_1.JavaDeclarationBlock()
59
55
  .access('public')
60
56
  .asKind('interface')
61
57
  .withName(this.convertName(node.name))
@@ -64,27 +60,27 @@ class JavaResolversVisitor extends visitorPluginCommon.BaseVisitor {
64
60
  }
65
61
  InterfaceTypeDefinition(node) {
66
62
  this._includeTypeResolverImport = true;
67
- return new javaCommon.JavaDeclarationBlock()
63
+ return new java_common_1.JavaDeclarationBlock()
68
64
  .access('public')
69
65
  .asKind('interface')
70
66
  .withName(this.convertName(node.name))
71
67
  .extends(['TypeResolver'])
72
68
  .withComment(node.description)
73
- .withBlock(node.fields.map(f => visitorPluginCommon.indent(f(true))).join('\n')).string;
69
+ .withBlock(node.fields.map(f => (0, visitor_plugin_common_1.indent)(f(true))).join('\n')).string;
74
70
  }
75
71
  ObjectTypeDefinition(node) {
76
- return new javaCommon.JavaDeclarationBlock()
72
+ return new java_common_1.JavaDeclarationBlock()
77
73
  .access('public')
78
74
  .asKind('interface')
79
75
  .withName(this.convertName(node.name))
80
76
  .withComment(node.description)
81
- .withBlock(node.fields.map(f => visitorPluginCommon.indent(f(false))).join('\n')).string;
77
+ .withBlock(node.fields.map(f => (0, visitor_plugin_common_1.indent)(f(false))).join('\n')).string;
82
78
  }
83
79
  FieldDefinition(node, key, _parent) {
84
80
  return (isInterface) => {
85
- const baseType = visitorPluginCommon.getBaseTypeNode(node.type);
81
+ const baseType = (0, visitor_plugin_common_1.getBaseTypeNode)(node.type);
86
82
  const typeToUse = this.getTypeToUse(baseType);
87
- const wrappedType = javaCommon.wrapTypeWithModifiers(typeToUse, node.type, this.config.listType);
83
+ const wrappedType = (0, java_common_1.wrapTypeWithModifiers)(typeToUse, node.type, this.config.listType);
88
84
  if (isInterface) {
89
85
  return `default public DataFetcher<${wrappedType}> ${node.name.value}() { return null; }`;
90
86
  }
@@ -92,18 +88,4 @@ class JavaResolversVisitor extends visitorPluginCommon.BaseVisitor {
92
88
  };
93
89
  }
94
90
  }
95
-
96
- const plugin = async (schema, documents, config, { outputFile }) => {
97
- const relevantPath = path.dirname(path.normalize(outputFile));
98
- const defaultPackageName = javaCommon.buildPackageNameFromPath(relevantPath);
99
- const visitor = new JavaResolversVisitor(config, schema, defaultPackageName);
100
- const astNode = pluginHelpers.getCachedDocumentNodeFromSchema(schema);
101
- const visitorResult = pluginHelpers.oldVisit(astNode, { leave: visitor });
102
- const mappersImports = visitor.getImports();
103
- const packageName = visitor.getPackageName();
104
- const blockContent = visitorResult.definitions.filter(d => typeof d === 'string').join('\n');
105
- const wrappedContent = visitor.wrapWithClass(blockContent);
106
- return [packageName, mappersImports, wrappedContent].join('\n');
107
- };
108
-
109
- exports.plugin = plugin;
91
+ 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 mappersImports = 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, mappersImports, wrappedContent].join('\n');
16
+ };
@@ -1,9 +1,6 @@
1
- import { getCachedDocumentNodeFromSchema, oldVisit } from '@graphql-codegen/plugin-helpers';
2
- import { BaseVisitor, transformMappers, parseMapper, buildScalarsFromConfig, indentMultiline, indent, getBaseTypeNode } from '@graphql-codegen/visitor-plugin-common';
3
- import { JAVA_SCALARS, JavaDeclarationBlock, wrapTypeWithModifiers, buildPackageNameFromPath } from '@graphql-codegen/java-common';
4
- import { dirname, normalize } from 'path';
5
-
6
- class JavaResolversVisitor extends BaseVisitor {
1
+ import { BaseVisitor, transformMappers, parseMapper, indent, indentMultiline, getBaseTypeNode, buildScalarsFromConfig, } from '@graphql-codegen/visitor-plugin-common';
2
+ import { JAVA_SCALARS, JavaDeclarationBlock, wrapTypeWithModifiers } from '@graphql-codegen/java-common';
3
+ export class JavaResolversVisitor extends BaseVisitor {
7
4
  constructor(rawConfig, _schema, defaultPackageName) {
8
5
  super(rawConfig, {
9
6
  mappers: transformMappers(rawConfig.mappers || {}),
@@ -88,18 +85,3 @@ class JavaResolversVisitor extends BaseVisitor {
88
85
  };
89
86
  }
90
87
  }
91
-
92
- const plugin = async (schema, documents, config, { outputFile }) => {
93
- const relevantPath = dirname(normalize(outputFile));
94
- const defaultPackageName = buildPackageNameFromPath(relevantPath);
95
- const visitor = new JavaResolversVisitor(config, schema, defaultPackageName);
96
- const astNode = getCachedDocumentNodeFromSchema(schema);
97
- const visitorResult = oldVisit(astNode, { leave: visitor });
98
- const mappersImports = visitor.getImports();
99
- const packageName = visitor.getPackageName();
100
- const blockContent = visitorResult.definitions.filter(d => typeof d === 'string').join('\n');
101
- const wrappedContent = visitor.wrapWithClass(blockContent);
102
- return [packageName, mappersImports, wrappedContent].join('\n');
103
- };
104
-
105
- export { plugin };
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@graphql-codegen/java-resolvers",
3
- "version": "2.2.13",
3
+ "version": "2.2.15-alpha-2cc8b095b.0",
4
4
  "description": "GraphQL Code Generator plugin for generating resolvers signature for Java backends",
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",
9
+ "@graphql-codegen/java-common": "^2.1.22-alpha-2cc8b095b.0",
10
10
  "@graphql-codegen/plugin-helpers": "^2.4.0",
11
- "@graphql-codegen/visitor-plugin-common": "2.9.1",
11
+ "@graphql-codegen/visitor-plugin-common": "2.11.0-alpha-2cc8b095b.0",
12
12
  "tslib": "~2.4.0"
13
13
  },
14
14
  "repository": {
@@ -17,21 +17,28 @@
17
17
  "directory": "packages/plugins/java/resolvers"
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, ParsedMapper } from '@graphql-codegen/visitor-plugin-common';
2
- import { JavaResolversPluginRawConfig } from './config';
2
+ import { JavaResolversPluginRawConfig } from './config.js';
3
3
  import { GraphQLSchema, NamedTypeNode, ObjectTypeDefinitionNode, FieldDefinitionNode, InterfaceTypeDefinitionNode } from 'graphql';
4
4
  import { UnionTypeDefinitionNode } from 'graphql/language/ast.js';
5
5
  export interface JavaResolverParsedConfig extends ParsedConfig {