Skip to content

Commit 99bf0de

Browse files
Bump version graphql-java from 17.2 to 20.2
1 parent b336020 commit 99bf0de

File tree

3 files changed

+12
-68
lines changed

3 files changed

+12
-68
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ gradle.projectsEvaluated {
5454

5555
dependencies {
5656
compile 'javax.validation:validation-api:1.1.0.Final'
57-
compile 'com.graphql-java:graphql-java:20.2'
57+
compile 'com.graphql-java:graphql-java:20.3'
5858
compile 'com.graphql-java:graphql-java-extended-scalars:20.2'
5959
compile 'javax.xml.bind:jaxb-api:2.3.1'
6060

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ org.gradle.daemon=true
55
org.gradle.parallel=true
66
org.gradle.jvmargs=-Dfile.encoding=UTF-8
77

8-
version = 20.2
8+
version = 20.3

src/main/java/graphql/annotations/processor/retrievers/fieldBuilders/DirectivesBuilder.java

Lines changed: 10 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,14 @@
1414
*/
1515
package graphql.annotations.processor.retrievers.fieldBuilders;
1616

17-
import graphql.Scalars;
17+
import java.lang.annotation.Annotation;
18+
import java.lang.reflect.AnnotatedElement;
19+
import java.lang.reflect.Method;
20+
import java.util.ArrayList;
21+
import java.util.Arrays;
22+
import java.util.List;
23+
import java.util.stream.Collectors;
24+
1825
import graphql.annotations.annotationTypes.directives.activation.GraphQLDirectives;
1926
import graphql.annotations.processor.ProcessingElementsContainer;
2027
import graphql.annotations.processor.exceptions.GraphQLAnnotationsException;
@@ -24,17 +31,6 @@
2431
import graphql.schema.GraphQLScalarType;
2532
import graphql.schema.GraphQLType;
2633

27-
import java.lang.annotation.Annotation;
28-
import java.lang.reflect.AnnotatedElement;
29-
import java.lang.reflect.Method;
30-
import java.math.BigDecimal;
31-
import java.util.ArrayList;
32-
import java.util.Arrays;
33-
import java.util.List;
34-
import java.util.stream.Collectors;
35-
36-
import static graphql.Assert.assertShouldNeverHappen;
37-
import static graphql.scalar.CoercingUtil.isNumberIsh;
3834
import static graphql.schema.GraphQLDirective.newDirective;
3935

4036

@@ -139,7 +135,7 @@ private void transformArgument(Annotation annotation, GraphQLDirective.Builder d
139135
Object value;
140136
if ( graphQLArgument.getType() instanceof GraphQLScalarType )
141137
{
142-
value = parseArgumentValue( graphQLArgument, argumentValue );
138+
value = ((GraphQLScalarType) graphQLArgument.getType()).getCoercing().parseValue(argumentValue);
143139
}
144140
else
145141
{
@@ -165,7 +161,7 @@ private void transformArgument(String[] argumentValues, GraphQLDirective.Builder
165161
if (graphQLArgument.getType() instanceof GraphQLScalarType) {
166162

167163
try {
168-
Object value = parseArgumentValue( graphQLArgument, argumentValue );
164+
Object value = ((GraphQLScalarType) graphQLArgument.getType()).getCoercing().parseValue(argumentValue);
169165
builder.value( value );
170166
} catch (Exception e) {
171167
throw new GraphQLAnnotationsException(COULD_NOT_PARSE_ARGUMENT_VALUE_TO_ARGUMENT_TYPE, e);
@@ -175,56 +171,4 @@ private void transformArgument(String[] argumentValues, GraphQLDirective.Builder
175171
}
176172
}));
177173
}
178-
179-
private Object parseArgumentValue( GraphQLArgument graphQLArgument, Object argumentValue )
180-
{
181-
GraphQLScalarType argumentType = (GraphQLScalarType) graphQLArgument.getType();
182-
if ( argumentType.equals( Scalars.GraphQLBoolean ) )
183-
{
184-
return castToBoolean( argumentValue );
185-
}
186-
else
187-
{
188-
return argumentType.getCoercing().parseValue( argumentValue );
189-
}
190-
}
191-
192-
private Boolean castToBoolean( Object input )
193-
{
194-
if ( input instanceof Boolean )
195-
{
196-
return (Boolean) input;
197-
}
198-
else if ( input instanceof String )
199-
{
200-
String lStr = ( (String) input ).toLowerCase();
201-
if ( lStr.equals( "true" ) )
202-
{
203-
return true;
204-
}
205-
if ( lStr.equals( "false" ) )
206-
{
207-
return false;
208-
}
209-
return null;
210-
}
211-
else if ( isNumberIsh( input ) )
212-
{
213-
BigDecimal value;
214-
try
215-
{
216-
value = new BigDecimal( input.toString() );
217-
}
218-
catch ( NumberFormatException e )
219-
{
220-
// this should never happen because String is handled above
221-
return assertShouldNeverHappen();
222-
}
223-
return value.compareTo( BigDecimal.ZERO ) != 0;
224-
}
225-
else
226-
{
227-
return null;
228-
}
229-
}
230174
}

0 commit comments

Comments
 (0)