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.KotlinResolversVisitor(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 packageName = visitor.getPackageName();
|
15 | const blockContent = visitorResult.definitions.filter(d => typeof d === 'string').join('\n\n');
|
16 | return [packageName, blockContent].join('\n');
|
17 | };
|
18 | exports.plugin = plugin;
|