Skip to content

Commit

Permalink
Use provided description for custom scalar if it exists
Browse files Browse the repository at this point in the history
  • Loading branch information
ehuisman authored and jmartisk committed Aug 30, 2024
1 parent 3ea8019 commit 4245649
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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();

Expand Down

0 comments on commit 4245649

Please sign in to comment.