From 693b2a3c8341fff5f9923fb5e3c0d58968a2f9c0 Mon Sep 17 00:00:00 2001 From: Eetu Huisman Date: Fri, 30 Aug 2024 09:51:19 +0300 Subject: [PATCH] Use provided description for custom scalar if it exists --- .../java/io/smallrye/graphql/bootstrap/Bootstrap.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/server/implementation/src/main/java/io/smallrye/graphql/bootstrap/Bootstrap.java b/server/implementation/src/main/java/io/smallrye/graphql/bootstrap/Bootstrap.java index bad83fa88..1eaf74ff6 100644 --- a/server/implementation/src/main/java/io/smallrye/graphql/bootstrap/Bootstrap.java +++ b/server/implementation/src/main/java/io/smallrye/graphql/bootstrap/Bootstrap.java @@ -252,11 +252,13 @@ private void createGraphQLCustomScalarTypes() { private void createGraphQLCustomScalarType(CustomScalarType customScalarType) { String scalarName = customScalarType.getName(); + String description = getDescription(customScalarType); + Coercing coercing = getCoercing(customScalarType); GraphQLScalarType graphQLScalarType = GraphQLScalarType.newScalar() .name(scalarName) - .description("Scalar for " + scalarName) + .description(description) .coercing(coercing) .build(); @@ -266,6 +268,11 @@ private void createGraphQLCustomScalarType(CustomScalarType customScalarType) { graphQLScalarType); } + private static String getDescription(CustomScalarType customScalarType) { + return Optional.ofNullable(customScalarType.getDescription()) + .orElse("Scalar for " + customScalarType.getName()); + } + private static Coercing getCoercing(CustomScalarType customScalarType) { CustomScalarPrimitiveType primitiveType = customScalarType.getCustomScalarPrimitiveType();