From 18d7195547c4370a5ff5177e843c96a391c481c1 Mon Sep 17 00:00:00 2001 From: Dan Adajian Date: Wed, 4 Jun 2025 13:06:56 -0500 Subject: [PATCH] fix: preserve case in directive name --- src/definitions/directive.ts | 2 +- test/unit/should_generate_custom_directives/expected.kt | 6 +++--- test/unit/should_generate_custom_directives/schema.graphql | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/definitions/directive.ts b/src/definitions/directive.ts index 2fc3dd7..56d9172 100644 --- a/src/definitions/directive.ts +++ b/src/definitions/directive.ts @@ -25,7 +25,7 @@ export function buildDirectiveDefinition( return ""; } return `@GraphQLDirective( - name = "${titleCase(directiveName)}", + name = "${directiveName}", description = "${node.description?.value ?? ""}", locations = [${node.locations.map((location) => `graphql.introspection.Introspection.DirectiveLocation.${location.value}`).join(", ")}] ) diff --git a/test/unit/should_generate_custom_directives/expected.kt b/test/unit/should_generate_custom_directives/expected.kt index 16e4e5c..c32da53 100644 --- a/test/unit/should_generate_custom_directives/expected.kt +++ b/test/unit/should_generate_custom_directives/expected.kt @@ -4,14 +4,14 @@ import com.expediagroup.graphql.generator.annotations.* import should_honor_directiveReplacements_config.* @GraphQLDirective( - name = "MyCustomDirective", - description = "A description for MyCustomDirective", + name = "myCustomDirective", + description = "A description for myCustomDirective", locations = [graphql.introspection.Introspection.DirectiveLocation.OBJECT, graphql.introspection.Introspection.DirectiveLocation.FIELD_DEFINITION, graphql.introspection.Introspection.DirectiveLocation.INPUT_OBJECT, graphql.introspection.Introspection.DirectiveLocation.INPUT_FIELD_DEFINITION] ) annotation class MyCustomDirective @GraphQLDirective( - name = "MyCustomDirective2", + name = "myCustomDirective2", description = "", locations = [graphql.introspection.Introspection.DirectiveLocation.OBJECT, graphql.introspection.Introspection.DirectiveLocation.FIELD_DEFINITION, graphql.introspection.Introspection.DirectiveLocation.INPUT_OBJECT, graphql.introspection.Introspection.DirectiveLocation.INPUT_FIELD_DEFINITION] ) diff --git a/test/unit/should_generate_custom_directives/schema.graphql b/test/unit/should_generate_custom_directives/schema.graphql index 0708d5c..ac8a825 100644 --- a/test/unit/should_generate_custom_directives/schema.graphql +++ b/test/unit/should_generate_custom_directives/schema.graphql @@ -1,4 +1,4 @@ -"A description for MyCustomDirective" +"A description for myCustomDirective" directive @myCustomDirective on OBJECT | FIELD_DEFINITION | INPUT_OBJECT | INPUT_FIELD_DEFINITION directive @myCustomDirective2 on OBJECT | FIELD_DEFINITION | INPUT_OBJECT | INPUT_FIELD_DEFINITION