Skip to content

Commit b684e9f

Browse files
author
Thomas Draier
committed
Code improvements
1 parent 8717fad commit b684e9f

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/main/java/graphql/annotations/GraphQLAnnotations.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ protected GraphQLFieldDefinition getField(Field field) throws GraphQLAnnotations
471471
}
472472

473473
GraphQLOutputType outputType = (GraphQLOutputType) typeFunction.buildType(field.getType(), field.getAnnotatedType());
474-
outputType = field.getAnnotation(NotNull.class) == null ? outputType : new GraphQLNonNull(outputType);
474+
outputType = field.isAnnotationPresent(NotNull.class) ? new GraphQLNonNull(outputType) : outputType;
475475

476476
boolean isConnection = isConnection(field, outputType);
477477
if (isConnection) {
@@ -577,22 +577,22 @@ private boolean checkIfPrefixGetterExists(Class c, String prefix, String propert
577577
}
578578

579579
private GraphQLOutputType getGraphQLConnection(AccessibleObject field, GraphQLOutputType type, GraphQLFieldDefinition.Builder builder) {
580-
boolean isNonNull = (type instanceof GraphQLNonNull);
581-
if (isNonNull) {
580+
if (type instanceof GraphQLNonNull) {
582581
type = (GraphQLOutputType) ((GraphQLNonNull) type).getWrappedType();
582+
return new GraphQLNonNull(internalGetGraphQLConnection(field, type, builder));
583+
} else {
584+
return internalGetGraphQLConnection(field, type, builder);
583585
}
586+
}
584587

588+
private GraphQLOutputType internalGetGraphQLConnection(AccessibleObject field, GraphQLOutputType type, GraphQLFieldDefinition.Builder builder) {
585589
graphql.schema.GraphQLType wrappedType = ((GraphQLList) type).getWrappedType();
586590
assert wrappedType instanceof GraphQLObjectType;
587-
String annValue = field.getAnnotation(GraphQLConnection.class).name();
588-
String connectionName = annValue.isEmpty() ? wrappedType.getName() : annValue;
591+
String connectionName = field.getAnnotation(GraphQLConnection.class).name();
592+
connectionName = connectionName.isEmpty() ? wrappedType.getName() : connectionName;
589593
GraphQLObjectType edgeType = relay.edgeType(connectionName, (GraphQLOutputType) wrappedType, null, Collections.<GraphQLFieldDefinition>emptyList());
590594
type = relay.connectionType(connectionName, edgeType, Collections.emptyList());
591595
builder.argument(relay.getConnectionFieldArguments());
592-
593-
if (isNonNull) {
594-
type = new GraphQLNonNull(type);
595-
}
596596
return type;
597597
}
598598

0 commit comments

Comments
 (0)