diff --git a/src/definitions/input.ts b/src/definitions/input.ts index bbfd265..0fd416c 100644 --- a/src/definitions/input.ts +++ b/src/definitions/input.ts @@ -56,7 +56,9 @@ export function buildInputObjectDefinition( definitionNode: node, }); - return `${annotations}data class ${node.name.value}( + const inputRestrictionAnnotation = + "@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.INPUT_OBJECT])\n"; + return `${annotations}${inputRestrictionAnnotation}data class ${node.name.value}( ${classMembers} )`; } diff --git a/src/definitions/object.ts b/src/definitions/object.ts index 29dbcb5..c16d3ef 100644 --- a/src/definitions/object.ts +++ b/src/definitions/object.ts @@ -24,6 +24,7 @@ import { isResolverType } from "../helpers/is-resolver-type"; import { buildFieldDefinition } from "../helpers/build-field-definition"; import { isExternalField } from "../helpers/is-external-field"; import { CodegenConfigWithDefaults } from "../helpers/build-config-with-defaults"; +import { inputTypeHasMatchingOutputType } from "../helpers/input-type-has-matching-output-type"; export function buildObjectTypeDefinition( node: ObjectTypeDefinitionNode, @@ -57,7 +58,14 @@ ${getDataClassMembers({ node, schema, config, completableFuture: true })} }`; } - return `${annotations}data class ${name}( + const potentialMatchingInputType = schema.getType(`${name}Input`)?.astNode; + const typeWillBeConsolidated = + potentialMatchingInputType?.kind === Kind.INPUT_OBJECT_TYPE_DEFINITION && + inputTypeHasMatchingOutputType(potentialMatchingInputType, schema); + const outputRestrictionAnnotation = typeWillBeConsolidated + ? "" + : "@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.OBJECT])\n"; + return `${annotations}${outputRestrictionAnnotation}data class ${name}( ${getDataClassMembers({ node, schema, config })} )${interfaceInheritance}`; } diff --git a/test/unit/should_annotate_types_properly/expected.kt b/test/unit/should_annotate_types_properly/expected.kt index 1ad5a55..2f578ac 100644 --- a/test/unit/should_annotate_types_properly/expected.kt +++ b/test/unit/should_annotate_types_properly/expected.kt @@ -3,6 +3,7 @@ package com.kotlin.generated import com.expediagroup.graphql.generator.annotations.* @GraphQLDescription("A description for MyType") +@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.OBJECT]) data class TypeThatShouldBeProperlyAnnotated( val field: String? = null, @GraphQLDescription("A description for fieldWithDescription") diff --git a/test/unit/should_consolidate_input_and_output_types/expected.kt b/test/unit/should_consolidate_input_and_output_types/expected.kt index 5ad0a2a..ecb33e7 100644 --- a/test/unit/should_consolidate_input_and_output_types/expected.kt +++ b/test/unit/should_consolidate_input_and_output_types/expected.kt @@ -25,28 +25,34 @@ data class MyTypeToConsolidate4( val field: String? = null ) +@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.OBJECT]) data class MyTypeNotToConsolidate( val field: String? = null ) @GraphQLDescription("The type name must exactly match in order to consolidate") +@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.INPUT_OBJECT]) data class MyTypeToNotConsolidateInput( val field: String? = null ) +@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.OBJECT]) data class MyTypeToNotConsolidate2( val field: String? = null ) +@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.INPUT_OBJECT]) data class MyTypeInputToNotConsolidate2( val field: String? = null ) +@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.OBJECT]) data class MyTypeWhereFieldsDoNotMatch( val field: String? = null, val field2: String? = null ) +@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.INPUT_OBJECT]) data class MyTypeWhereFieldsDoNotMatchInput( val field: String? = null, val field2: Int? = null diff --git a/test/unit/should_convert_graphql_float_to_kotlin_double/expected.kt b/test/unit/should_convert_graphql_float_to_kotlin_double/expected.kt index 64d6c41..8b5ace2 100644 --- a/test/unit/should_convert_graphql_float_to_kotlin_double/expected.kt +++ b/test/unit/should_convert_graphql_float_to_kotlin_double/expected.kt @@ -2,6 +2,7 @@ package com.kotlin.generated import com.expediagroup.graphql.generator.annotations.* +@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.OBJECT]) data class MyFloatType( val field: Double? = null ) diff --git a/test/unit/should_default_non_nullable_boolean_fields_to_false/expected.kt b/test/unit/should_default_non_nullable_boolean_fields_to_false/expected.kt index 4a8680a..e466ee1 100644 --- a/test/unit/should_default_non_nullable_boolean_fields_to_false/expected.kt +++ b/test/unit/should_default_non_nullable_boolean_fields_to_false/expected.kt @@ -2,6 +2,7 @@ package com.kotlin.generated import com.expediagroup.graphql.generator.annotations.* +@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.OBJECT]) data class MyBooleanType( val field: Boolean = false, val field2: Boolean? = null diff --git a/test/unit/should_generate_field_resolver_interfaces/expected.kt b/test/unit/should_generate_field_resolver_interfaces/expected.kt index 12d5406..f0a6055 100644 --- a/test/unit/should_generate_field_resolver_interfaces/expected.kt +++ b/test/unit/should_generate_field_resolver_interfaces/expected.kt @@ -18,6 +18,7 @@ interface QueryCompletableFuture { fun nonNullableResolver(arg: InputTypeGenerateFieldResolverInterfaces): java.util.concurrent.CompletableFuture } +@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.INPUT_OBJECT]) data class InputTypeGenerateFieldResolverInterfaces( val field: String? = null ) diff --git a/test/unit/should_generate_input_types_properly/expected.kt b/test/unit/should_generate_input_types_properly/expected.kt index ac9316d..3d5e1fd 100644 --- a/test/unit/should_generate_input_types_properly/expected.kt +++ b/test/unit/should_generate_input_types_properly/expected.kt @@ -3,6 +3,7 @@ package com.kotlin.generated import com.expediagroup.graphql.generator.annotations.* @GraphQLDescription("A description for MyInputType") +@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.INPUT_OBJECT]) data class InputTypeThatShouldBeGeneratedProperly( val field1: String? = null, @GraphQLDescription("A description for field2") diff --git a/test/unit/should_generate_interfaces_with_inheritance/expected.kt b/test/unit/should_generate_interfaces_with_inheritance/expected.kt index 972bbe0..9868688 100644 --- a/test/unit/should_generate_interfaces_with_inheritance/expected.kt +++ b/test/unit/should_generate_interfaces_with_inheritance/expected.kt @@ -9,6 +9,7 @@ interface InterfaceWithInheritance { } @GraphQLDescription("A description for MyInterfaceImplementation") +@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.OBJECT]) data class MyInterfaceImplementation( override val field: String? = null, override val field2: String @@ -22,6 +23,7 @@ interface InheritedInterface2 { val field2: String } +@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.OBJECT]) data class MyMergedInterfaceImplementation( override val field: String? = null, override val field2: String diff --git a/test/unit/should_generate_list_types_properly/expected.kt b/test/unit/should_generate_list_types_properly/expected.kt index 0211f11..9a51690 100644 --- a/test/unit/should_generate_list_types_properly/expected.kt +++ b/test/unit/should_generate_list_types_properly/expected.kt @@ -2,6 +2,7 @@ package com.kotlin.generated import com.expediagroup.graphql.generator.annotations.* +@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.OBJECT]) data class MyListType( val field: List = emptyList(), val field2: List = emptyList(), diff --git a/test/unit/should_generate_multi_union_types_properly/expected.kt b/test/unit/should_generate_multi_union_types_properly/expected.kt index f5bd4a8..438919a 100644 --- a/test/unit/should_generate_multi_union_types_properly/expected.kt +++ b/test/unit/should_generate_multi_union_types_properly/expected.kt @@ -2,10 +2,12 @@ package com.kotlin.generated import com.expediagroup.graphql.generator.annotations.* +@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.OBJECT]) data class MyType3( val field: String? = null ) : MyUnion1, MyUnion2 +@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.OBJECT]) data class MyType4( val field: String? = null ) : MyUnion1, MyUnion2 @@ -14,6 +16,7 @@ interface MyUnion1 interface MyUnion2 +@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.OBJECT]) data class MyMultiUnionType( val field: MyUnion1? = null, val field2: MyUnion2? = null 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 aa7142b..4a32299 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,10 +3,12 @@ package com.kotlin.generated import com.expediagroup.graphql.generator.annotations.* @GraphQLDescription("A description for MyType1") +@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.OBJECT]) data class TypeForNonNullableUnionList1( val field: String? = null ) : UnionForNonNullableList +@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.OBJECT]) data class TypeForNonNullableUnionList2( val field: String? = null ) : UnionForNonNullableList @@ -14,6 +16,7 @@ data class TypeForNonNullableUnionList2( @GraphQLDescription("A description for UnionForNonNullableList") interface UnionForNonNullableList +@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.OBJECT]) data class MyNonNullableUnionListType( val field: List = emptyList(), val field2: List = emptyList() diff --git a/test/unit/should_generate_type_with_interface_field_type/expected.kt b/test/unit/should_generate_type_with_interface_field_type/expected.kt index a9b8498..bf2df51 100644 --- a/test/unit/should_generate_type_with_interface_field_type/expected.kt +++ b/test/unit/should_generate_type_with_interface_field_type/expected.kt @@ -8,6 +8,7 @@ interface MyInterface { val field2: String } +@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.OBJECT]) data class MyInterfaceFieldType( val field: MyInterface? = null, val field2: MyInterface 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 d35f292..da3c097 100644 --- a/test/unit/should_generate_union_list_types_properly/expected.kt +++ b/test/unit/should_generate_union_list_types_properly/expected.kt @@ -3,10 +3,12 @@ package com.kotlin.generated import com.expediagroup.graphql.generator.annotations.* @GraphQLDescription("A description for TypeForGeneratingUnionListTypes1") +@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.OBJECT]) data class TypeForGeneratingUnionListTypes1( val field: String? = null ) : UnionForGeneratingUnionListTypes +@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.OBJECT]) data class TypeForGeneratingUnionListTypes2( val field: String? = null ) : UnionForGeneratingUnionListTypes @@ -14,6 +16,7 @@ data class TypeForGeneratingUnionListTypes2( @GraphQLDescription("A description for UnionForGeneratingUnionListTypes") interface UnionForGeneratingUnionListTypes +@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.OBJECT]) data class MyUnionListType( @GraphQLDescription("A description for field") val field: List? = null, diff --git a/test/unit/should_generate_union_types_properly/expected.kt b/test/unit/should_generate_union_types_properly/expected.kt index a06a063..6078ae7 100644 --- a/test/unit/should_generate_union_types_properly/expected.kt +++ b/test/unit/should_generate_union_types_properly/expected.kt @@ -3,10 +3,12 @@ package com.kotlin.generated import com.expediagroup.graphql.generator.annotations.* @GraphQLDescription("A description for MyType1") +@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.OBJECT]) data class TypeForGeneratingUnionTypesProperly1( val field: String? = null ) : UnionForGeneratingUnionsProperly +@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.OBJECT]) data class TypeForGeneratingUnionTypesProperly2( val field: String? = null ) : UnionForGeneratingUnionsProperly @@ -14,6 +16,7 @@ data class TypeForGeneratingUnionTypesProperly2( @GraphQLDescription("A trimmed description for UnionForGeneratingUnionsProperly") interface UnionForGeneratingUnionsProperly +@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.OBJECT]) data class MyUnionType( @GraphQLDescription("A description for field") val field: UnionForGeneratingUnionsProperly? = null, diff --git a/test/unit/should_honor_dependentTypesInScope_config/expected.kt b/test/unit/should_honor_dependentTypesInScope_config/expected.kt index e7ea92e..e247581 100644 --- a/test/unit/should_honor_dependentTypesInScope_config/expected.kt +++ b/test/unit/should_honor_dependentTypesInScope_config/expected.kt @@ -3,11 +3,13 @@ package com.kotlin.generated import com.expediagroup.graphql.generator.annotations.* import should_honor_dependentTypesInScope_config.* +@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.OBJECT]) data class MyTypeInOnlyTypes( val field: TypeInScope, val field2: TypeOutOfScope ) +@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.OBJECT]) data class TypeInScope( val field: String? = null, val unionInScopeField: UnionInScope? = null, @@ -17,6 +19,7 @@ data class TypeInScope( interface UnionInScope +@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.OBJECT]) data class Type1( val field: String? = null ) : UnionInScope, ExternalUnionAsInterface diff --git a/test/unit/should_honor_directiveReplacements_config/expected.kt b/test/unit/should_honor_directiveReplacements_config/expected.kt index b353397..8292a5c 100644 --- a/test/unit/should_honor_directiveReplacements_config/expected.kt +++ b/test/unit/should_honor_directiveReplacements_config/expected.kt @@ -7,6 +7,7 @@ import should_honor_directiveReplacements_config.* @SomeAnnotation1 @SomeAnnotation2 @SomeAnnotationWithArgs(arg1 = "arg1", arg2 = 0) +@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.OBJECT]) data class TypeHonoringDirectiveReplacements( val field: String? = null ) : MyDirectiveUnion 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 2f115f8..01eaa19 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 @@ -6,6 +6,7 @@ import should_honor_directiveReplacements_config.* @GraphQLDescription("A description for MyDirectiveType") @SomeAnnotation1 @SomeAnnotation2 +@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.OBJECT]) data class TypeHonoringDirectiveReplacementsMultipleDirectives( val field: String? = null ) diff --git a/test/unit/should_honor_directiveReplacements_definitionType_config/expected.kt b/test/unit/should_honor_directiveReplacements_definitionType_config/expected.kt index 77c0abd..6529c6b 100644 --- a/test/unit/should_honor_directiveReplacements_definitionType_config/expected.kt +++ b/test/unit/should_honor_directiveReplacements_definitionType_config/expected.kt @@ -5,12 +5,14 @@ import should_honor_directiveReplacements_config.* @SomeAnnotation1 @CommonAnnotation +@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.OBJECT]) data class TypeHonoringDirectiveReplacementsDefinitionType( val field: String? = null ) @SomeAnnotation2 @CommonAnnotation +@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.INPUT_OBJECT]) data class MyDirectiveTypeInput( val field: String? = null ) diff --git a/test/unit/should_honor_includeDependentTypes_config/expected.kt b/test/unit/should_honor_includeDependentTypes_config/expected.kt index 3224d78..a90f0f8 100644 --- a/test/unit/should_honor_includeDependentTypes_config/expected.kt +++ b/test/unit/should_honor_includeDependentTypes_config/expected.kt @@ -2,6 +2,7 @@ package com.kotlin.generated import com.expediagroup.graphql.generator.annotations.* +@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.OBJECT]) data class TypeHonoringIncludeDependentTypesConfig( val field: MyNestedType? = null ) diff --git a/test/unit/should_honor_onlyTypes_config/expected.kt b/test/unit/should_honor_onlyTypes_config/expected.kt index 6997a70..f3b955d 100644 --- a/test/unit/should_honor_onlyTypes_config/expected.kt +++ b/test/unit/should_honor_onlyTypes_config/expected.kt @@ -2,6 +2,7 @@ package com.kotlin.generated import com.expediagroup.graphql.generator.annotations.* +@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.OBJECT]) data class TypeHonoringOnlyTypesConfig( val field1: String? = null, @GraphQLDescription("A description for field2") diff --git a/test/unit/should_honor_packageName_config/expected.kt b/test/unit/should_honor_packageName_config/expected.kt index 1be7ccb..62b3684 100644 --- a/test/unit/should_honor_packageName_config/expected.kt +++ b/test/unit/should_honor_packageName_config/expected.kt @@ -2,6 +2,7 @@ package com.some.custom.name import com.expediagroup.graphql.generator.annotations.* +@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.OBJECT]) data class TypeHonoringPackageNameConfig( val field: String? = null ) diff --git a/test/unit/should_honor_resolverTypes_config/expected.kt b/test/unit/should_honor_resolverTypes_config/expected.kt index 71216a2..efa09f7 100644 --- a/test/unit/should_honor_resolverTypes_config/expected.kt +++ b/test/unit/should_honor_resolverTypes_config/expected.kt @@ -30,6 +30,7 @@ interface MyIncludedResolverTypeCompletableFuture { fun nonNullableField(): java.util.concurrent.CompletableFuture } +@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.OBJECT]) data class MyExcludedResolverType( val nullableField: String? = null, val nonNullableField: String diff --git a/test/unit/should_honor_union_generation_config/expected.kt b/test/unit/should_honor_union_generation_config/expected.kt index faab3b8..e8d5b95 100644 --- a/test/unit/should_honor_union_generation_config/expected.kt +++ b/test/unit/should_honor_union_generation_config/expected.kt @@ -3,10 +3,12 @@ package com.kotlin.generated import com.expediagroup.graphql.generator.annotations.* @GraphQLDescription("A description for TypeForHonoringUnionGenerationConfig1") +@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.OBJECT]) data class TypeForHonoringUnionGenerationConfig1( val field: String? = null ) +@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.OBJECT]) data class TypeForHonoringUnionGenerationConfig2( val field: String? = null ) @@ -18,6 +20,7 @@ data class TypeForHonoringUnionGenerationConfig2( ) annotation class UnionAsAnnotation +@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.OBJECT]) data class UnionForHonoringUnionGenerationConfig( @UnionAsAnnotation @GraphQLDescription("A description for field") diff --git a/test/unit/should_include_dependent_types_in_onlyTypes_config/expected.kt b/test/unit/should_include_dependent_types_in_onlyTypes_config/expected.kt index 1895564..4b9bc86 100644 --- a/test/unit/should_include_dependent_types_in_onlyTypes_config/expected.kt +++ b/test/unit/should_include_dependent_types_in_onlyTypes_config/expected.kt @@ -2,6 +2,7 @@ package com.kotlin.generated import com.expediagroup.graphql.generator.annotations.* +@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.OBJECT]) data class MyType( val typeField: MyNestedType, val typeListField: List = emptyList(), @@ -12,14 +13,17 @@ data class MyType( val interfaceImplementationField: MyImplementedInterface ) +@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.OBJECT]) data class MyNestedType( val field: String? = null ) +@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.OBJECT]) data class ListType( val field: List? = null ) +@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.OBJECT]) data class NestedListType( val field: String? = null ) @@ -35,14 +39,17 @@ enum class MyEnum { interface MyUnion +@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.OBJECT]) data class MyType1( val field: String? = null ) : MyUnion +@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.OBJECT]) data class MyType2( val field: String? = null ) : MyUnion +@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.OBJECT]) data class UnionImplementation( val field: String? = null ) : MyUnion2 @@ -55,24 +62,29 @@ interface MyInterfaceToImplement { val field: String? } +@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.OBJECT]) data class MyImplementedInterface( override val field: String? = null ) : MyInterfaceToImplement +@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.INPUT_OBJECT]) data class MyInput( val field: MyNestedInput ) +@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.INPUT_OBJECT]) data class MyNestedInput( val field: String? = null ) interface MyStandaloneUnion +@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.OBJECT]) data class StandaloneUnionType( val field: StandaloneNestedType? = null ) : MyStandaloneUnion +@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.OBJECT]) data class StandaloneNestedType( val field: String? = null ) diff --git a/test/unit/should_replace_federation_directives/expected.kt b/test/unit/should_replace_federation_directives/expected.kt index 7e94aa0..fb52b50 100644 --- a/test/unit/should_replace_federation_directives/expected.kt +++ b/test/unit/should_replace_federation_directives/expected.kt @@ -4,6 +4,7 @@ import com.expediagroup.graphql.generator.annotations.* @com.expediagroup.graphql.generator.federation.directives.ExtendsDirective @com.expediagroup.graphql.generator.federation.directives.KeyDirective(com.expediagroup.graphql.generator.federation.directives.FieldSet("some field")) +@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.OBJECT]) data class FederatedType( @com.expediagroup.graphql.generator.federation.directives.ExternalDirective val field: String diff --git a/test/unit/should_support_custom_scalars/expected.kt b/test/unit/should_support_custom_scalars/expected.kt index c290325..4543a7a 100644 --- a/test/unit/should_support_custom_scalars/expected.kt +++ b/test/unit/should_support_custom_scalars/expected.kt @@ -2,12 +2,14 @@ package com.kotlin.generated import com.expediagroup.graphql.generator.annotations.* +@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.OBJECT]) data class MyScalarType( val idField: com.expediagroup.graphql.generator.scalars.ID? = null, val field: java.net.URL? = null, val field2: java.net.URL ) +@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.OBJECT]) data class MyCustomScalarType( val field: String? = null, val field2: String