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 34592be
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.smallrye.graphql.schema.helper;

import io.smallrye.graphql.schema.SchemaBuilderException;
import org.jboss.jandex.Type;
import org.jboss.logging.Logger;

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 34592be

Please sign in to comment.