diff --git a/gradle.properties b/gradle.properties index 0c20904..1e50bcd 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,6 +5,6 @@ maven.central.sync=false sonatype.username=DUMMY_SONATYPE_USER sonatype.password=DUMMY_SONATYPE_PASSWORD -PROJECT_VERSION=1.1.0 +PROJECT_VERSION=1.1.1 PROJECT_GITHUB_REPO_URL=https://github.com/nfl/glitr PROJECT_LICENSE_URL=https://github.com/nfl/glitr/blob/master/LICENSE \ No newline at end of file diff --git a/src/main/java/com/nfl/glitr/annotation/GlitrArgument.java b/src/main/java/com/nfl/glitr/annotation/GlitrArgument.java index 423c141..c8b8d4a 100644 --- a/src/main/java/com/nfl/glitr/annotation/GlitrArgument.java +++ b/src/main/java/com/nfl/glitr/annotation/GlitrArgument.java @@ -19,6 +19,8 @@ String name(); Class type(); boolean nullable() default true; - String defaultValue() default "No Default Value"; String description() default "No Description"; + + String NO_DEFAULT_VALUE = "No Default Value"; + String defaultValue() default NO_DEFAULT_VALUE; } diff --git a/src/main/java/com/nfl/glitr/registry/TypeRegistry.java b/src/main/java/com/nfl/glitr/registry/TypeRegistry.java index 2246746..cff69b8 100644 --- a/src/main/java/com/nfl/glitr/registry/TypeRegistry.java +++ b/src/main/java/com/nfl/glitr/registry/TypeRegistry.java @@ -151,7 +151,7 @@ public GraphQLType lookupOutput(Class clazz) { } /** - * Check if the given class if found the registry, if not, first create it ({@link GraphQLInputType}), next add it + * Check if the given class is found in the registry, if not, first create it ({@link GraphQLInputType}), then add it * to the registry * * @param clazz class on which to preform input introspection @@ -239,11 +239,17 @@ private GraphQLArgument createRelayInputArgument(Class methodDeclaringClass, Met inputType = new GraphQLNonNull(inputType); } + // Default values need to match type so we replace our default String with null + Object defaultValue = null; + if (!arg.defaultValue().equalsIgnoreCase(GlitrArgument.NO_DEFAULT_VALUE)) { + defaultValue = arg.defaultValue(); + } + return newArgument() .name(arg.name()) .description(arg.description()) .type(inputType) - .defaultValue(arg.defaultValue()) + .defaultValue(defaultValue) .build(); } @@ -419,7 +425,7 @@ public GraphQLOutputType retrieveGraphQLOutputType(Class declaringClass, Method GraphQLOutputType graphQLOutputType; String name = ReflectionUtil.sanitizeMethodName(method.getName()); - graphQLOutputType = getGraphQLOutputTypeFromAnnotationsOnGetter(declaringClass, method, null); + graphQLOutputType = getGraphQLOutputTypeFromAnnotationsOnGetter(declaringClass, method); graphQLOutputType = getGraphQLOutputTypeFromAnnotationsOnField(declaringClass, method, graphQLOutputType, name); // default OutputType @@ -468,7 +474,8 @@ private Field getFieldByName(Class declaringClass, String name) { return field; } - private GraphQLOutputType getGraphQLOutputTypeFromAnnotationsOnGetter(Class declaringClass, Method method, GraphQLOutputType graphQLOutputType) { + private GraphQLOutputType getGraphQLOutputTypeFromAnnotationsOnGetter(Class declaringClass, Method method) { + GraphQLOutputType graphQLOutputType = null; Annotation[] methodAnnotations = method.getDeclaredAnnotations(); for (Annotation annotation: methodAnnotations) { // custom OutputType