Skip to content

Commit

Permalink
Throw an error when both DefaultValue and NonNull are present
Browse files Browse the repository at this point in the history
  • Loading branch information
jmartisk committed Sep 10, 2024
1 parent 01f7b74 commit c1e5d14
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import io.smallrye.graphql.schema.Annotations;
import io.smallrye.graphql.schema.Classes;
import io.smallrye.graphql.schema.SchemaBuilderException;

/**
* Helping to figure out of some should be marked as Non null
Expand Down Expand Up @@ -55,7 +56,7 @@ public static boolean markAsNonNull(Type type, Annotations annotations, boolean
boolean hasDefaultValue = hasDefaultValue(annotations);
if (hasDefaultValue) {
if (hasNonNull && !type.kind().equals(Type.Kind.PRIMITIVE)) {
LOG.warn("Ignoring non null on [" + type.name() + "] as there is a @DefaultValue");
throw new SchemaBuilderException("You can't have both @NonNull and @DefaultValue on [" + type.name() + "]");
}
return false;
}
Expand Down

0 comments on commit c1e5d14

Please sign in to comment.