@expediagroup/graphql-kotlin-codegen
Advanced tools
Comparing version 1.0.1 to 1.0.2
import { PluginFunction } from '@graphql-codegen/plugin-helpers'; | ||
import { RawConfig } from '@graphql-codegen/visitor-plugin-common'; | ||
import { RawConfig, ParsedConfig } from '@graphql-codegen/visitor-plugin-common'; | ||
import * as valibot from 'valibot'; | ||
@@ -138,5 +138,5 @@ import { Input } from 'valibot'; | ||
type GraphQLKotlinCodegenConfig = RawConfig & Input<typeof configSchema>; | ||
type GraphQLKotlinCodegenConfig = RawConfig & ParsedConfig & Input<typeof configSchema>; | ||
declare const plugin: PluginFunction<GraphQLKotlinCodegenConfig>; | ||
export { type GraphQLKotlinCodegenConfig, plugin }; |
@@ -131,3 +131,5 @@ "use strict"; | ||
const enumName = node.name.value; | ||
const enumValues = (0, import_visitor_plugin_common2.indentMultiline)((node.values ?? []).join(",\n") + ";", 2); | ||
const enumValues = node.values?.map((valueNode) => { | ||
return buildEnumValueDefinition(valueNode, config); | ||
}) ?? []; | ||
const annotations = buildAnnotations({ | ||
@@ -138,3 +140,3 @@ config, | ||
return `${annotations}enum class ${enumName}(val label: String) { | ||
${enumValues} | ||
${(0, import_visitor_plugin_common2.indentMultiline)(enumValues.join(",\n") + ";", 2)} | ||
@@ -149,11 +151,8 @@ companion object { | ||
} | ||
function buildEnumValueDefinition(node) { | ||
function buildEnumValueDefinition(node, config) { | ||
const annotations = buildAnnotations({ | ||
config: this.config, | ||
config, | ||
definitionNode: node | ||
}); | ||
return `${annotations}${this.convertName(node, { | ||
useTypesPrefix: false, | ||
transformUnderscore: true | ||
})}("${node.name.value}")`; | ||
return `${annotations}${config.convert(node)}("${node.name.value}")`; | ||
} | ||
@@ -442,3 +441,3 @@ | ||
// src/visitor.ts | ||
var KotlinResolversVisitor = class extends import_visitor_plugin_common7.BaseVisitor { | ||
var KotlinVisitor = class extends import_visitor_plugin_common7.BaseVisitor { | ||
constructor(rawConfig, _schema) { | ||
@@ -448,5 +447,2 @@ super(rawConfig, rawConfig); | ||
} | ||
EnumValueDefinition(node) { | ||
return buildEnumValueDefinition.bind(this)(node); | ||
} | ||
EnumTypeDefinition(node) { | ||
@@ -588,2 +584,3 @@ return buildEnumTypeDefinition(node, this.config); | ||
// src/plugin.ts | ||
var import_graphql7 = require("graphql"); | ||
var plugin = (schema, _, config, info) => { | ||
@@ -603,7 +600,5 @@ if (!info?.outputFile) { | ||
addDependentTypes(config, schema); | ||
const visitor = new KotlinResolversVisitor(config, schema); | ||
const visitor = new KotlinVisitor(config, schema); | ||
const astNode = (0, import_plugin_helpers.getCachedDocumentNodeFromSchema)(schema); | ||
const visitorResult = (0, import_plugin_helpers.oldVisit)(astNode, { | ||
leave: visitor | ||
}); | ||
const { definitions } = (0, import_graphql7.visit)(astNode, visitor); | ||
const packageName = `package ${config.packageName ?? (0, import_java_common2.buildPackageNameFromPath)(relevantPath)} | ||
@@ -613,3 +608,3 @@ `; | ||
const imports = defaultImports.concat(config.extraImports ?? []).map((annotation) => `import ${annotation}`).join("\n") + "\n"; | ||
const typeDefinitions = visitorResult.definitions.filter((d) => typeof d === "string" && d.length).join("\n\n"); | ||
const typeDefinitions = definitions.filter((d) => typeof d === "string" && d.length).join("\n\n"); | ||
return [packageName, imports, typeDefinitions].join("\n") + "\n"; | ||
@@ -616,0 +611,0 @@ }; |
@@ -48,3 +48,3 @@ { | ||
}, | ||
"version": "1.0.1" | ||
"version": "1.0.2" | ||
} |
# GraphQL Kotlin Codegen | ||
![GraphQL](https://img.shields.io/badge/-GraphQL-E10098?style=for-the-badge&logo=graphql&logoColor=white) | ||
![Kotlin](https://img.shields.io/badge/kotlin-%237F52FF.svg?style=for-the-badge&logo=kotlin&logoColor=%23600C9C) | ||
![Release](https://github.com/ExpediaGroup/graphql-kotlin-codegen/workflows/Publish/badge.svg) | ||
<a href="https://github.com/ExpediaGroup/graphql-kotlin-codegen/releases/latest"><img alt="latest-release" src="https://img.shields.io/github/v/release/ExpediaGroup/graphql-kotlin-codegen"/></a> | ||
GraphQL Kotlin Codegen is a plugin for [graphql-codegen](https://the-guild.dev/graphql/codegen) that generates Kotlin code from | ||
@@ -8,14 +13,16 @@ [Schema Definition Language (SDL)](https://www.apollographql.com/tutorials/lift-off-part1/03-schema-definition-language-sdl). | ||
Visit our [documentation site](https://opensource.expediagroup.com/graphql-kotlin-codegen/) for more details. | ||
## 📋 Docs | ||
## Contributions | ||
Check out our <a href="https://opensource.expediagroup.com/graphql-kotlin-codegen/" target="_blank">documentation site</a>!. | ||
## ✏️ Contributions | ||
- To get started, please fork the repo and checkout a new branch. See [CONTRIBUTING.md](./CONTRIBUTING.md) for details. | ||
## Contact | ||
## 👥 Contact | ||
This project is part of [Expedia Group Open Source](https://expediagroup.github.io) but also maintained by a dedicated team. | ||
## License | ||
## ⚖️ License | ||
This project is available under the [Apache 2.0 License](./LICENSE). |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
45318
28
0
716