diff --git a/build.gradle.kts b/build.gradle.kts index e0c5478..5a026d8 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -12,9 +12,10 @@ dependencies { } sourceSets { - main { + test { kotlin { - srcDirs("test/integration") + srcDirs("test/unit", "test/integration") + exclude("**/actual.kt") } } } diff --git a/package.json b/package.json index 15482b6..e648420 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "build": "tsup src/plugin.ts --clean --dts --external graphql", "format": "prettier --write .", "format-check": "prettier --check .", - "integration": "bun run build && graphql-codegen && ./gradlew compileKotlin", + "integration": "bun run build && graphql-codegen && ./gradlew compileTestKotlin", "lint": "eslint .", "prepack": "bun run build", "prepare": "husky", diff --git a/test/unit/should_annotate_types_properly/expected.kt b/test/unit/should_annotate_types_properly/expected.kt index 91d0f18..4c16759 100644 --- a/test/unit/should_annotate_types_properly/expected.kt +++ b/test/unit/should_annotate_types_properly/expected.kt @@ -3,7 +3,7 @@ package com.kotlin.generated import com.expediagroup.graphql.generator.annotations.* @GraphQLDescription("A description for MyType") -data class MyType( +data class TypeThatShouldBeProperlyAnnotated( val username: String? = null, @GraphQLDescription("A description for email") val email: String? = null, @@ -17,20 +17,20 @@ data class MyType( val deprecated3: String? = null, @Deprecated("It only takes the first one") val deprecated4: String? = null, - @MyUnion + @UnionThatShouldBeProperlyAnnotated @GraphQLDescription("DEPRECATED: It uses the GraphQLDescription annotation for union types") val deprecated5: Any? = null, - @MyUnion + @UnionThatShouldBeProperlyAnnotated @GraphQLDescription("It uses the GraphQLDescription annotation for union types") val deprecated6: Any? = null, - @MyUnion + @UnionThatShouldBeProperlyAnnotated @GraphQLDescription("When there is a description") val deprecated7: Any? = null ) @GraphQLUnion( - name = "MyUnion", - possibleTypes = [MyType::class], + name = "UnionThatShouldBeProperlyAnnotated", + possibleTypes = [TypeThatShouldBeProperlyAnnotated::class], description = "" ) -annotation class MyUnion +annotation class UnionThatShouldBeProperlyAnnotated diff --git a/test/unit/should_annotate_types_properly/schema.graphql b/test/unit/should_annotate_types_properly/schema.graphql index 45a889a..8bd8911 100644 --- a/test/unit/should_annotate_types_properly/schema.graphql +++ b/test/unit/should_annotate_types_properly/schema.graphql @@ -3,7 +3,7 @@ A "description" for MyType It can be multiline """ -type MyType { +type TypeThatShouldBeProperlyAnnotated { username: String "A description for email" email: String @@ -19,14 +19,14 @@ type MyType { deprecated4: String @deprecated(reason: "when you have multiple deprecated annotations") "DEPRECATED: It uses the GraphQLDescription annotation for union types" - deprecated5: MyUnion - deprecated6: MyUnion + deprecated5: UnionThatShouldBeProperlyAnnotated + deprecated6: UnionThatShouldBeProperlyAnnotated @deprecated( reason: "It uses the GraphQLDescription annotation for union types" ) "When there is a description" - deprecated7: MyUnion + deprecated7: UnionThatShouldBeProperlyAnnotated @deprecated(reason: "It omits the @Deprecated annotation for now") } -union MyUnion = MyType +union UnionThatShouldBeProperlyAnnotated = TypeThatShouldBeProperlyAnnotated diff --git a/test/unit/should_generate_enums_properly/expected.kt b/test/unit/should_generate_enums_properly/expected.kt index 37c6c41..e4c7d94 100644 --- a/test/unit/should_generate_enums_properly/expected.kt +++ b/test/unit/should_generate_enums_properly/expected.kt @@ -3,12 +3,12 @@ package com.kotlin.generated import com.expediagroup.graphql.generator.annotations.* @GraphQLDescription("A description for MyEnum") -enum class MyEnum { +enum class EnumThatShouldBeProperlyAnnotated { This, @GraphQLDescription("A description for THAT") That; companion object { - fun findByName(name: String, ignoreCase: Boolean = false): MyEnum? = values().find { it.name.equals(name, ignoreCase = ignoreCase) } + fun findByName(name: String, ignoreCase: Boolean = false): EnumThatShouldBeProperlyAnnotated? = values().find { it.name.equals(name, ignoreCase = ignoreCase) } } } diff --git a/test/unit/should_generate_enums_properly/schema.graphql b/test/unit/should_generate_enums_properly/schema.graphql index cdcbad0..71d7642 100644 --- a/test/unit/should_generate_enums_properly/schema.graphql +++ b/test/unit/should_generate_enums_properly/schema.graphql @@ -1,5 +1,5 @@ "A description for MyEnum" -enum MyEnum { +enum EnumThatShouldBeProperlyAnnotated { THIS "A description for THAT" THAT diff --git a/test/unit/should_generate_field_resolver_interfaces/expected.kt b/test/unit/should_generate_field_resolver_interfaces/expected.kt index f6aed08..12d5406 100644 --- a/test/unit/should_generate_field_resolver_interfaces/expected.kt +++ b/test/unit/should_generate_field_resolver_interfaces/expected.kt @@ -7,7 +7,7 @@ interface Query { suspend fun nullableField(): FieldType? = null suspend fun nonNullableField(): FieldType suspend fun nullableResolver(arg: String): String? = null - suspend fun nonNullableResolver(arg: MyInputType): String + suspend fun nonNullableResolver(arg: InputTypeGenerateFieldResolverInterfaces): String } @GraphQLIgnore @@ -15,10 +15,10 @@ interface QueryCompletableFuture { fun nullableField(): java.util.concurrent.CompletableFuture fun nonNullableField(): java.util.concurrent.CompletableFuture fun nullableResolver(arg: String): java.util.concurrent.CompletableFuture - fun nonNullableResolver(arg: MyInputType): java.util.concurrent.CompletableFuture + fun nonNullableResolver(arg: InputTypeGenerateFieldResolverInterfaces): java.util.concurrent.CompletableFuture } -data class MyInputType( +data class InputTypeGenerateFieldResolverInterfaces( val field: String? = null ) diff --git a/test/unit/should_generate_field_resolver_interfaces/schema.graphql b/test/unit/should_generate_field_resolver_interfaces/schema.graphql index 59ecfe4..ff57062 100644 --- a/test/unit/should_generate_field_resolver_interfaces/schema.graphql +++ b/test/unit/should_generate_field_resolver_interfaces/schema.graphql @@ -2,10 +2,10 @@ type Query { nullableField: FieldType nonNullableField: FieldType! nullableResolver(arg: String!): String - nonNullableResolver(arg: MyInputType!): String! + nonNullableResolver(arg: InputTypeGenerateFieldResolverInterfaces!): String! } -input MyInputType { +input InputTypeGenerateFieldResolverInterfaces { field: String } diff --git a/test/unit/should_generate_input_types_properly/expected.kt b/test/unit/should_generate_input_types_properly/expected.kt index fd7a52c..f5bb75c 100644 --- a/test/unit/should_generate_input_types_properly/expected.kt +++ b/test/unit/should_generate_input_types_properly/expected.kt @@ -3,7 +3,7 @@ package com.kotlin.generated import com.expediagroup.graphql.generator.annotations.* @GraphQLDescription("A description for MyInputType") -data class MyInputType( +data class InputTypeThatShouldBeGeneratedProperly( val username: String? = null, @GraphQLDescription("A description for email") val email: String? = null, diff --git a/test/unit/should_generate_input_types_properly/schema.graphql b/test/unit/should_generate_input_types_properly/schema.graphql index f5e3732..0072b3e 100644 --- a/test/unit/should_generate_input_types_properly/schema.graphql +++ b/test/unit/should_generate_input_types_properly/schema.graphql @@ -1,5 +1,5 @@ "A description for MyInputType" -input MyInputType { +input InputTypeThatShouldBeGeneratedProperly { username: String "A description for email" email: String diff --git a/test/unit/should_generate_interfaces_with_inheritance/expected.kt b/test/unit/should_generate_interfaces_with_inheritance/expected.kt index 8246fd2..972bbe0 100644 --- a/test/unit/should_generate_interfaces_with_inheritance/expected.kt +++ b/test/unit/should_generate_interfaces_with_inheritance/expected.kt @@ -2,8 +2,8 @@ package com.kotlin.generated import com.expediagroup.graphql.generator.annotations.* -@GraphQLDescription("A description for MyInterface") -interface MyInterface { +@GraphQLDescription("A description for InterfaceWithInheritance") +interface InterfaceWithInheritance { val field: String? val field2: String } @@ -12,17 +12,17 @@ interface MyInterface { data class MyInterfaceImplementation( override val field: String? = null, override val field2: String -) : MyInterface +) : InterfaceWithInheritance -interface MyInterface1 { +interface InheritedInterface1 { val field: String? } -interface MyInterface2 { +interface InheritedInterface2 { val field2: String } data class MyMergedInterfaceImplementation( override val field: String? = null, override val field2: String -) : MyInterface1, MyInterface2 +) : InheritedInterface1, InheritedInterface2 diff --git a/test/unit/should_generate_interfaces_with_inheritance/schema.graphql b/test/unit/should_generate_interfaces_with_inheritance/schema.graphql index 646f285..90826cb 100644 --- a/test/unit/should_generate_interfaces_with_inheritance/schema.graphql +++ b/test/unit/should_generate_interfaces_with_inheritance/schema.graphql @@ -1,24 +1,24 @@ -"A description for MyInterface" -interface MyInterface { +"A description for InterfaceWithInheritance" +interface InterfaceWithInheritance { field: String field2: String! } "A description for MyInterfaceImplementation" -type MyInterfaceImplementation implements MyInterface { +type MyInterfaceImplementation implements InterfaceWithInheritance { field: String field2: String! } -interface MyInterface1 { +interface InheritedInterface1 { field: String } -interface MyInterface2 { +interface InheritedInterface2 { field2: String! } -type MyMergedInterfaceImplementation implements MyInterface1 & MyInterface2 { +type MyMergedInterfaceImplementation implements InheritedInterface1 & InheritedInterface2 { field: String field2: String! } diff --git a/test/unit/should_generate_non-nullable_union_list_types_properly/expected.kt b/test/unit/should_generate_non-nullable_union_list_types_properly/expected.kt index 67c0e7a..3cf852b 100644 --- a/test/unit/should_generate_non-nullable_union_list_types_properly/expected.kt +++ b/test/unit/should_generate_non-nullable_union_list_types_properly/expected.kt @@ -3,24 +3,24 @@ package com.kotlin.generated import com.expediagroup.graphql.generator.annotations.* @GraphQLDescription("A description for MyType1") -data class MyType1( +data class TypeForNonNullableUnionList1( val field: String? = null ) -data class MyType2( +data class TypeForNonNullableUnionList2( val field: String? = null ) @GraphQLUnion( - name = "MyUnion", - possibleTypes = [MyType1::class, MyType2::class], - description = "A description for MyUnion" + name = "UnionForNonNullableList", + possibleTypes = [TypeForNonNullableUnionList1::class, TypeForNonNullableUnionList2::class], + description = "A description for UnionForNonNullableList" ) -annotation class MyUnion +annotation class UnionForNonNullableList data class MyNonNullableUnionListType( - @MyUnion + @UnionForNonNullableList val field: List = emptyList(), - @MyUnion + @UnionForNonNullableList val field2: List = emptyList() ) diff --git a/test/unit/should_generate_non-nullable_union_list_types_properly/schema.graphql b/test/unit/should_generate_non-nullable_union_list_types_properly/schema.graphql index cc3f227..6f66253 100644 --- a/test/unit/should_generate_non-nullable_union_list_types_properly/schema.graphql +++ b/test/unit/should_generate_non-nullable_union_list_types_properly/schema.graphql @@ -1,16 +1,18 @@ "A description for MyType1" -type MyType1 { +type TypeForNonNullableUnionList1 { field: String } -type MyType2 { +type TypeForNonNullableUnionList2 { field: String } -"A description for MyUnion" -union MyUnion = MyType1 | MyType2 +"A description for UnionForNonNullableList" +union UnionForNonNullableList = + | TypeForNonNullableUnionList1 + | TypeForNonNullableUnionList2 type MyNonNullableUnionListType { - field: [MyUnion!]! - field2: [MyUnion]! + field: [UnionForNonNullableList!]! + field2: [UnionForNonNullableList]! } diff --git a/test/unit/should_generate_union_list_types_properly/expected.kt b/test/unit/should_generate_union_list_types_properly/expected.kt index fb1b133..1777385 100644 --- a/test/unit/should_generate_union_list_types_properly/expected.kt +++ b/test/unit/should_generate_union_list_types_properly/expected.kt @@ -2,26 +2,26 @@ package com.kotlin.generated import com.expediagroup.graphql.generator.annotations.* -@GraphQLDescription("A description for MyType1") -data class MyType1( +@GraphQLDescription("A description for TypeForGeneratingUnionListTypes1") +data class TypeForGeneratingUnionListTypes1( val field: String? = null ) -data class MyType2( +data class TypeForGeneratingUnionListTypes2( val field: String? = null ) @GraphQLUnion( - name = "MyUnion", - possibleTypes = [MyType1::class, MyType2::class], - description = "A description for MyUnion" + name = "UnionForGeneratingUnionListTypes", + possibleTypes = [TypeForGeneratingUnionListTypes1::class, TypeForGeneratingUnionListTypes2::class], + description = "A description for UnionForGeneratingUnionListTypes" ) -annotation class MyUnion +annotation class UnionForGeneratingUnionListTypes data class MyUnionListType( - @MyUnion + @UnionForGeneratingUnionListTypes @GraphQLDescription("A description for field") val field: List? = null, - @MyUnion + @UnionForGeneratingUnionListTypes val field2: List? = null ) diff --git a/test/unit/should_generate_union_list_types_properly/schema.graphql b/test/unit/should_generate_union_list_types_properly/schema.graphql index 2178272..6c1fe26 100644 --- a/test/unit/should_generate_union_list_types_properly/schema.graphql +++ b/test/unit/should_generate_union_list_types_properly/schema.graphql @@ -1,17 +1,19 @@ -"A description for MyType1" -type MyType1 { +"A description for TypeForGeneratingUnionListTypes1" +type TypeForGeneratingUnionListTypes1 { field: String } -type MyType2 { +type TypeForGeneratingUnionListTypes2 { field: String } -"A description for MyUnion" -union MyUnion = MyType1 | MyType2 +"A description for UnionForGeneratingUnionListTypes" +union UnionForGeneratingUnionListTypes = + | TypeForGeneratingUnionListTypes1 + | TypeForGeneratingUnionListTypes2 type MyUnionListType { "A description for field" - field: [MyUnion!] - field2: [MyUnion] + field: [UnionForGeneratingUnionListTypes!] + field2: [UnionForGeneratingUnionListTypes] } diff --git a/test/unit/should_generate_union_types_properly/expected.kt b/test/unit/should_generate_union_types_properly/expected.kt index 9ae03d0..229f757 100644 --- a/test/unit/should_generate_union_types_properly/expected.kt +++ b/test/unit/should_generate_union_types_properly/expected.kt @@ -3,23 +3,23 @@ package com.kotlin.generated import com.expediagroup.graphql.generator.annotations.* @GraphQLDescription("A description for MyType1") -data class MyType1( +data class TypeForGeneratingUnionTypesProperly1( val field: String? = null ) -data class MyType2( +data class TypeForGeneratingUnionTypesProperly2( val field: String? = null ) @GraphQLUnion( - name = "MyUnion", - possibleTypes = [MyType1::class, MyType2::class], - description = "A trimmed description for MyUnion" + name = "UnionForGeneratingUnionsProperly", + possibleTypes = [TypeForGeneratingUnionTypesProperly1::class, TypeForGeneratingUnionTypesProperly2::class], + description = "A trimmed description for UnionForGeneratingUnionsProperly" ) -annotation class MyUnion +annotation class UnionForGeneratingUnionsProperly data class MyUnionType( - @MyUnion + @UnionForGeneratingUnionsProperly @GraphQLDescription("A description for field") val field: Any? = null, val field2: String? = null diff --git a/test/unit/should_generate_union_types_properly/schema.graphql b/test/unit/should_generate_union_types_properly/schema.graphql index 5a06f6f..d514335 100644 --- a/test/unit/should_generate_union_types_properly/schema.graphql +++ b/test/unit/should_generate_union_types_properly/schema.graphql @@ -1,19 +1,21 @@ "A description for MyType1" -type MyType1 { +type TypeForGeneratingUnionTypesProperly1 { field: String } -type MyType2 { +type TypeForGeneratingUnionTypesProperly2 { field: String } """ -A "trimmed" description for MyUnion +A "trimmed" description for UnionForGeneratingUnionsProperly """ -union MyUnion = MyType1 | MyType2 +union UnionForGeneratingUnionsProperly = + | TypeForGeneratingUnionTypesProperly1 + | TypeForGeneratingUnionTypesProperly2 type MyUnionType { "A description for field" - field: MyUnion + field: UnionForGeneratingUnionsProperly field2: String } diff --git a/test/unit/should_honor_base_configs/expected.kt b/test/unit/should_honor_base_configs/expected.kt index 0666734..50a1c49 100644 --- a/test/unit/should_honor_base_configs/expected.kt +++ b/test/unit/should_honor_base_configs/expected.kt @@ -3,12 +3,12 @@ package com.kotlin.generated import com.expediagroup.graphql.generator.annotations.* @GraphQLDescription("A description for MyEnum") -enum class MyEnum { +enum class EnumHonoringBaseConfigs { THIS, @GraphQLDescription("A description for THAT") THAT; companion object { - fun findByName(name: String, ignoreCase: Boolean = false): MyEnum? = values().find { it.name.equals(name, ignoreCase = ignoreCase) } + fun findByName(name: String, ignoreCase: Boolean = false): EnumHonoringBaseConfigs? = values().find { it.name.equals(name, ignoreCase = ignoreCase) } } } diff --git a/test/unit/should_honor_base_configs/schema.graphql b/test/unit/should_honor_base_configs/schema.graphql index cdcbad0..0236d7b 100644 --- a/test/unit/should_honor_base_configs/schema.graphql +++ b/test/unit/should_honor_base_configs/schema.graphql @@ -1,5 +1,5 @@ "A description for MyEnum" -enum MyEnum { +enum EnumHonoringBaseConfigs { THIS "A description for THAT" THAT diff --git a/test/unit/should_honor_dependentTypesInScope_config/codegen.config.ts b/test/unit/should_honor_dependentTypesInScope_config/codegen.config.ts index 0403aab..5989dc4 100644 --- a/test/unit/should_honor_dependentTypesInScope_config/codegen.config.ts +++ b/test/unit/should_honor_dependentTypesInScope_config/codegen.config.ts @@ -1,11 +1,7 @@ import { GraphQLKotlinCodegenConfig } from "../../../src/plugin"; export default { - extraImports: [ - "com.some.import.TypeOutOfScope", - "com.some.import.UnionOutOfScope", - "com.some.import.ExternalUnionAsInterface", - ], + extraImports: ["should_honor_dependentTypesInScope_config.*"], onlyTypes: ["MyTypeInOnlyTypes"], dependentTypesInScope: ["TypeInScope", "UnionInScope", "Type1"], externalUnionsAsInterfaces: ["ExternalUnionAsInterface"], diff --git a/test/unit/should_honor_dependentTypesInScope_config/expected.kt b/test/unit/should_honor_dependentTypesInScope_config/expected.kt index f36e946..6096c18 100644 --- a/test/unit/should_honor_dependentTypesInScope_config/expected.kt +++ b/test/unit/should_honor_dependentTypesInScope_config/expected.kt @@ -1,9 +1,7 @@ package com.kotlin.generated import com.expediagroup.graphql.generator.annotations.* -import com.some.import.TypeOutOfScope -import com.some.import.UnionOutOfScope -import com.some.import.ExternalUnionAsInterface +import should_honor_dependentTypesInScope_config.* data class MyTypeInOnlyTypes( val field: TypeInScope, diff --git a/test/unit/should_honor_dependentTypesInScope_config/externalClasses.kt b/test/unit/should_honor_dependentTypesInScope_config/externalClasses.kt new file mode 100644 index 0000000..cd9d127 --- /dev/null +++ b/test/unit/should_honor_dependentTypesInScope_config/externalClasses.kt @@ -0,0 +1,7 @@ +package should_honor_dependentTypesInScope_config + +data class TypeOutOfScope(val value: String) + +interface ExternalUnionAsInterface + +annotation class UnionOutOfScope diff --git a/test/unit/should_honor_directiveReplacements_config/codegen.config.ts b/test/unit/should_honor_directiveReplacements_config/codegen.config.ts index b1cb0e6..9f41d06 100644 --- a/test/unit/should_honor_directiveReplacements_config/codegen.config.ts +++ b/test/unit/should_honor_directiveReplacements_config/codegen.config.ts @@ -1,6 +1,7 @@ import { GraphQLKotlinCodegenConfig } from "../../../src/plugin"; export default { + extraImports: ["should_honor_directiveReplacements_config.*"], directiveReplacements: [ { directive: "directive1", @@ -10,7 +11,7 @@ export default { directive: "directiveWithArgs", kotlinAnnotations: [ { - annotationName: "SomeAnnotation3", + annotationName: "SomeAnnotationWithArgs", argumentsToRetain: ["arg1", "arg2"], }, ], diff --git a/test/unit/should_honor_directiveReplacements_config/expected.kt b/test/unit/should_honor_directiveReplacements_config/expected.kt index 70bde82..08dd3dc 100644 --- a/test/unit/should_honor_directiveReplacements_config/expected.kt +++ b/test/unit/should_honor_directiveReplacements_config/expected.kt @@ -1,12 +1,13 @@ package com.kotlin.generated import com.expediagroup.graphql.generator.annotations.* +import should_honor_directiveReplacements_config.* @GraphQLDescription("A description for MyDirectiveType") @SomeAnnotation1 @SomeAnnotation2 -@SomeAnnotation3(arg1 = "arg1", arg2 = 0) -data class MyDirectiveType( +@SomeAnnotationWithArgs(arg1 = "arg1", arg2 = 0) +data class TypeHonoringDirectiveReplacements( val field: String? = null ) @@ -14,7 +15,7 @@ data class MyDirectiveType( @SomeAnnotation2 @GraphQLUnion( name = "MyDirectiveUnion", - possibleTypes = [MyDirectiveType::class], + possibleTypes = [TypeHonoringDirectiveReplacements::class], description = "A description for MyDirectiveUnion" ) annotation class MyDirectiveUnion diff --git a/test/unit/should_honor_directiveReplacements_config/schema.graphql b/test/unit/should_honor_directiveReplacements_config/schema.graphql index 4444e17..cf170d1 100644 --- a/test/unit/should_honor_directiveReplacements_config/schema.graphql +++ b/test/unit/should_honor_directiveReplacements_config/schema.graphql @@ -2,9 +2,11 @@ directive @directive1 on OBJECT | UNION directive @directiveWithArgs(arg1: String, arg2: Int) on OBJECT | UNION "A description for MyDirectiveType" -type MyDirectiveType @directive1 @directiveWithArgs(arg1: "arg1", arg2: 0) { +type TypeHonoringDirectiveReplacements + @directive1 + @directiveWithArgs(arg1: "arg1", arg2: 0) { field: String } "A description for MyDirectiveUnion" -union MyDirectiveUnion @directive1 = MyDirectiveType +union MyDirectiveUnion @directive1 = TypeHonoringDirectiveReplacements diff --git a/test/unit/should_honor_directiveReplacements_config/someAnnotations.kt b/test/unit/should_honor_directiveReplacements_config/someAnnotations.kt new file mode 100644 index 0000000..128e47f --- /dev/null +++ b/test/unit/should_honor_directiveReplacements_config/someAnnotations.kt @@ -0,0 +1,6 @@ +package should_honor_directiveReplacements_config + +annotation class SomeAnnotation1 +annotation class SomeAnnotation2 +annotation class SomeAnnotationWithArgs(val arg1: String, val arg2: Int) +annotation class CommonAnnotation diff --git a/test/unit/should_honor_directiveReplacements_config_with_multiple_directives/codegen.config.ts b/test/unit/should_honor_directiveReplacements_config_with_multiple_directives/codegen.config.ts index 6b48de8..2a8040a 100644 --- a/test/unit/should_honor_directiveReplacements_config_with_multiple_directives/codegen.config.ts +++ b/test/unit/should_honor_directiveReplacements_config_with_multiple_directives/codegen.config.ts @@ -1,6 +1,7 @@ import { GraphQLKotlinCodegenConfig } from "../../../src/plugin"; export default { + extraImports: ["should_honor_directiveReplacements_config.*"], directiveReplacements: [ { directive: "directive1", diff --git a/test/unit/should_honor_directiveReplacements_config_with_multiple_directives/expected.kt b/test/unit/should_honor_directiveReplacements_config_with_multiple_directives/expected.kt index 3ecc721..2f115f8 100644 --- a/test/unit/should_honor_directiveReplacements_config_with_multiple_directives/expected.kt +++ b/test/unit/should_honor_directiveReplacements_config_with_multiple_directives/expected.kt @@ -1,10 +1,11 @@ package com.kotlin.generated import com.expediagroup.graphql.generator.annotations.* +import should_honor_directiveReplacements_config.* @GraphQLDescription("A description for MyDirectiveType") @SomeAnnotation1 @SomeAnnotation2 -data class MyDirectiveType( +data class TypeHonoringDirectiveReplacementsMultipleDirectives( val field: String? = null ) diff --git a/test/unit/should_honor_directiveReplacements_config_with_multiple_directives/schema.graphql b/test/unit/should_honor_directiveReplacements_config_with_multiple_directives/schema.graphql index 8e3f906..34095d3 100644 --- a/test/unit/should_honor_directiveReplacements_config_with_multiple_directives/schema.graphql +++ b/test/unit/should_honor_directiveReplacements_config_with_multiple_directives/schema.graphql @@ -2,6 +2,8 @@ directive @directive1 on OBJECT directive @directive2 on OBJECT "A description for MyDirectiveType" -type MyDirectiveType @directive1 @directive2 { +type TypeHonoringDirectiveReplacementsMultipleDirectives + @directive1 + @directive2 { field: String } diff --git a/test/unit/should_honor_directiveReplacements_definitionType_config/codegen.config.ts b/test/unit/should_honor_directiveReplacements_definitionType_config/codegen.config.ts index 94ac279..da7c1e2 100644 --- a/test/unit/should_honor_directiveReplacements_definitionType_config/codegen.config.ts +++ b/test/unit/should_honor_directiveReplacements_definitionType_config/codegen.config.ts @@ -2,15 +2,16 @@ import { GraphQLKotlinCodegenConfig } from "../../../src/plugin"; import { Kind } from "graphql/index"; export default { + extraImports: ["should_honor_directiveReplacements_config.*"], directiveReplacements: [ { directive: "directive1", - kotlinAnnotations: ["@SomeInputAnnotation"], + kotlinAnnotations: ["@SomeAnnotation2"], definitionType: Kind.INPUT_OBJECT_TYPE_DEFINITION, }, { directive: "directive1", - kotlinAnnotations: ["@SomeAnnotation"], + kotlinAnnotations: ["@SomeAnnotation1"], }, { directive: "directive2", diff --git a/test/unit/should_honor_directiveReplacements_definitionType_config/expected.kt b/test/unit/should_honor_directiveReplacements_definitionType_config/expected.kt index f96ada6..77c0abd 100644 --- a/test/unit/should_honor_directiveReplacements_definitionType_config/expected.kt +++ b/test/unit/should_honor_directiveReplacements_definitionType_config/expected.kt @@ -1,14 +1,15 @@ package com.kotlin.generated import com.expediagroup.graphql.generator.annotations.* +import should_honor_directiveReplacements_config.* -@SomeAnnotation +@SomeAnnotation1 @CommonAnnotation -data class MyDirectiveType( +data class TypeHonoringDirectiveReplacementsDefinitionType( val field: String? = null ) -@SomeInputAnnotation +@SomeAnnotation2 @CommonAnnotation data class MyDirectiveTypeInput( val field: String? = null diff --git a/test/unit/should_honor_directiveReplacements_definitionType_config/schema.graphql b/test/unit/should_honor_directiveReplacements_definitionType_config/schema.graphql index 1a4d307..675138d 100644 --- a/test/unit/should_honor_directiveReplacements_definitionType_config/schema.graphql +++ b/test/unit/should_honor_directiveReplacements_definitionType_config/schema.graphql @@ -1,7 +1,7 @@ directive @directive1 on INPUT_OBJECT | OBJECT directive @directive2 on INPUT_OBJECT | OBJECT -type MyDirectiveType @directive1 @directive2 { +type TypeHonoringDirectiveReplacementsDefinitionType @directive1 @directive2 { field: String } diff --git a/test/unit/should_honor_includeDependentTypes_config/codegen.config.ts b/test/unit/should_honor_includeDependentTypes_config/codegen.config.ts index c07182d..d94632d 100644 --- a/test/unit/should_honor_includeDependentTypes_config/codegen.config.ts +++ b/test/unit/should_honor_includeDependentTypes_config/codegen.config.ts @@ -1,6 +1,6 @@ import { GraphQLKotlinCodegenConfig } from "../../../src/plugin"; export default { - onlyTypes: ["MyType"], + onlyTypes: ["TypeHonoringIncludeDependentTypesConfig"], includeDependentTypes: false, } satisfies GraphQLKotlinCodegenConfig; diff --git a/test/unit/should_honor_includeDependentTypes_config/expected.kt b/test/unit/should_honor_includeDependentTypes_config/expected.kt index fb6cb3a..3224d78 100644 --- a/test/unit/should_honor_includeDependentTypes_config/expected.kt +++ b/test/unit/should_honor_includeDependentTypes_config/expected.kt @@ -2,6 +2,6 @@ package com.kotlin.generated import com.expediagroup.graphql.generator.annotations.* -data class MyType( +data class TypeHonoringIncludeDependentTypesConfig( val field: MyNestedType? = null ) diff --git a/test/unit/should_honor_includeDependentTypes_config/schema.graphql b/test/unit/should_honor_includeDependentTypes_config/schema.graphql index c0505cb..af2b911 100644 --- a/test/unit/should_honor_includeDependentTypes_config/schema.graphql +++ b/test/unit/should_honor_includeDependentTypes_config/schema.graphql @@ -1,4 +1,4 @@ -type MyType { +type TypeHonoringIncludeDependentTypesConfig { field: MyNestedType } diff --git a/test/unit/should_honor_onlyTypes_config/codegen.config.ts b/test/unit/should_honor_onlyTypes_config/codegen.config.ts index a14dd1c..ef1f171 100644 --- a/test/unit/should_honor_onlyTypes_config/codegen.config.ts +++ b/test/unit/should_honor_onlyTypes_config/codegen.config.ts @@ -1,5 +1,5 @@ import { GraphQLKotlinCodegenConfig } from "../../../src/plugin"; export default { - onlyTypes: ["MyType", "MyEnum"], + onlyTypes: ["TypeHonoringOnlyTypesConfig", "EnumHonoringOnlyTypesConfig"], } satisfies GraphQLKotlinCodegenConfig; diff --git a/test/unit/should_honor_onlyTypes_config/expected.kt b/test/unit/should_honor_onlyTypes_config/expected.kt index 6bedc2f..9bea03e 100644 --- a/test/unit/should_honor_onlyTypes_config/expected.kt +++ b/test/unit/should_honor_onlyTypes_config/expected.kt @@ -2,7 +2,7 @@ package com.kotlin.generated import com.expediagroup.graphql.generator.annotations.* -data class MyType( +data class TypeHonoringOnlyTypesConfig( val username: String? = null, @GraphQLDescription("A description for email") val email: String? = null, @@ -11,12 +11,12 @@ data class MyType( ) @GraphQLDescription("A description for MyEnum") -enum class MyEnum { +enum class EnumHonoringOnlyTypesConfig { This, @GraphQLDescription("A description for THAT") That; companion object { - fun findByName(name: String, ignoreCase: Boolean = false): MyEnum? = values().find { it.name.equals(name, ignoreCase = ignoreCase) } + fun findByName(name: String, ignoreCase: Boolean = false): EnumHonoringOnlyTypesConfig? = values().find { it.name.equals(name, ignoreCase = ignoreCase) } } } diff --git a/test/unit/should_honor_onlyTypes_config/schema.graphql b/test/unit/should_honor_onlyTypes_config/schema.graphql index fdd4292..e21a829 100644 --- a/test/unit/should_honor_onlyTypes_config/schema.graphql +++ b/test/unit/should_honor_onlyTypes_config/schema.graphql @@ -1,4 +1,4 @@ -type MyType { +type TypeHonoringOnlyTypesConfig { username: String "A description for email" email: String @@ -9,7 +9,7 @@ type MyType { } "A description for MyEnum" -enum MyEnum { +enum EnumHonoringOnlyTypesConfig { THIS "A description for THAT" THAT diff --git a/test/unit/should_honor_packageName_config/expected.kt b/test/unit/should_honor_packageName_config/expected.kt index bcc7b52..1be7ccb 100644 --- a/test/unit/should_honor_packageName_config/expected.kt +++ b/test/unit/should_honor_packageName_config/expected.kt @@ -2,6 +2,6 @@ package com.some.custom.name import com.expediagroup.graphql.generator.annotations.* -data class MyType2( +data class TypeHonoringPackageNameConfig( val field: String? = null ) diff --git a/test/unit/should_honor_packageName_config/schema.graphql b/test/unit/should_honor_packageName_config/schema.graphql index 80a5031..94b7a72 100644 --- a/test/unit/should_honor_packageName_config/schema.graphql +++ b/test/unit/should_honor_packageName_config/schema.graphql @@ -1,3 +1,3 @@ -type MyType2 { +type TypeHonoringPackageNameConfig { field: String } diff --git a/test/unit/should_support_custom_scalars/codegen.config.ts b/test/unit/should_support_custom_scalars/codegen.config.ts index c5151a1..c345f3d 100644 --- a/test/unit/should_support_custom_scalars/codegen.config.ts +++ b/test/unit/should_support_custom_scalars/codegen.config.ts @@ -4,7 +4,7 @@ export default { extraScalars: [ { scalarName: "URL", - kotlinType: "URL", + kotlinType: "java.net.URL", }, ], } satisfies GraphQLKotlinCodegenConfig; diff --git a/test/unit/should_support_custom_scalars/expected.kt b/test/unit/should_support_custom_scalars/expected.kt index 0043250..c290325 100644 --- a/test/unit/should_support_custom_scalars/expected.kt +++ b/test/unit/should_support_custom_scalars/expected.kt @@ -4,8 +4,8 @@ import com.expediagroup.graphql.generator.annotations.* data class MyScalarType( val idField: com.expediagroup.graphql.generator.scalars.ID? = null, - val field: URL? = null, - val field2: URL + val field: java.net.URL? = null, + val field2: java.net.URL ) data class MyCustomScalarType(