Skip to content

Commit 3139ccb

Browse files
authored
Merge pull request #2325 from graphql-java/literal-to-value-coercing
implement default value coercion and validation
2 parents fdd8d1a + a72796d commit 3139ccb

68 files changed

Lines changed: 1646 additions & 2143 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/main/java/graphql/Scalars.java

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
package graphql;
22

33

4-
import graphql.scalar.GraphqlBigDecimalCoercing;
5-
import graphql.scalar.GraphqlBigIntegerCoercing;
64
import graphql.scalar.GraphqlBooleanCoercing;
7-
import graphql.scalar.GraphqlByteCoercing;
8-
import graphql.scalar.GraphqlCharCoercing;
95
import graphql.scalar.GraphqlFloatCoercing;
106
import graphql.scalar.GraphqlIDCoercing;
117
import graphql.scalar.GraphqlIntCoercing;
12-
import graphql.scalar.GraphqlLongCoercing;
13-
import graphql.scalar.GraphqlShortCoercing;
148
import graphql.scalar.GraphqlStringCoercing;
159
import graphql.schema.GraphQLScalarType;
1610

@@ -61,61 +55,4 @@ public class Scalars {
6155
*/
6256
public static final GraphQLScalarType GraphQLID = GraphQLScalarType.newScalar()
6357
.name("ID").description("Built-in ID").coercing(new GraphqlIDCoercing()).build();
64-
65-
/**
66-
* This represents the "Long" type which is a representation of java.lang.Long
67-
*
68-
* @deprecated The is a non standard scalar and is difficult for clients (such as browser and mobile code) to cope with
69-
* the exact semantics. These will be removed in the future version and moved to another library.
70-
*/
71-
public static final GraphQLScalarType GraphQLLong = GraphQLScalarType.newScalar()
72-
.name("Long").description("Long type").coercing(new GraphqlLongCoercing()).build();
73-
74-
/**
75-
* This represents the "Short" type which is a representation of java.lang.Short
76-
*
77-
* @deprecated The is a non standard scalar and is difficult for clients (such as browser and mobile code) to cope with
78-
* the exact semantics. These will be removed in the future version and moved to another library.
79-
*/
80-
public static final GraphQLScalarType GraphQLShort = GraphQLScalarType.newScalar()
81-
.name("Short").description("Built-in Short as Int").coercing(new GraphqlShortCoercing()).build();
82-
83-
/**
84-
* This represents the "Byte" type which is a representation of java.lang.Byte
85-
*
86-
* @deprecated The is a non standard scalar and is difficult for clients (such as browser and mobile code) to cope with
87-
* the exact semantics. These will be removed in the future version and moved to another library.
88-
*/
89-
public static final GraphQLScalarType GraphQLByte = GraphQLScalarType.newScalar()
90-
.name("Byte").description("Built-in Byte as Int").coercing(new GraphqlByteCoercing()).build();
91-
92-
93-
/**
94-
* This represents the "BigInteger" type which is a representation of java.math.BigInteger
95-
*
96-
* @deprecated The is a non standard scalar and is difficult for clients (such as browser and mobile code) to cope with
97-
* the exact semantics. These will be removed in the future version and moved to another library.
98-
*/
99-
public static final GraphQLScalarType GraphQLBigInteger = GraphQLScalarType.newScalar()
100-
.name("BigInteger").description("Built-in java.math.BigInteger").coercing(new GraphqlBigIntegerCoercing()).build();
101-
102-
/**
103-
* This represents the "BigDecimal" type which is a representation of java.math.BigDecimal
104-
*
105-
* @deprecated The is a non standard scalar and is difficult for clients (such as browser and mobile code) to cope with
106-
* the exact semantics. These will be removed in the future version and moved to another library.
107-
*/
108-
public static final GraphQLScalarType GraphQLBigDecimal = GraphQLScalarType.newScalar()
109-
.name("BigDecimal").description("Built-in java.math.BigDecimal").coercing(new GraphqlBigDecimalCoercing()).build();
110-
111-
112-
/**
113-
* This represents the "Char" type which is a representation of java.lang.Character
114-
*
115-
* @deprecated The is a non standard scalar and is difficult for clients (such as browser and mobile code) to cope with
116-
* the exact semantics. These will be removed in the future version and moved to another library.
117-
*/
118-
public static final GraphQLScalarType GraphQLChar = GraphQLScalarType.newScalar()
119-
.name("Char").description("Built-in Char as Character").coercing(new GraphqlCharCoercing()).build();
120-
12158
}

src/main/java/graphql/execution/NonNullableValueCoercedAsNullException.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ public NonNullableValueCoercedAsNullException(VariableDefinition variableDefinit
4242
this.path = path;
4343
}
4444

45+
public NonNullableValueCoercedAsNullException(String fieldName, List<Object> path, GraphQLType graphQLType) {
46+
super(format("Field '%s' has coerced Null value for NonNull type '%s'",
47+
fieldName, GraphQLTypeUtil.simplePrint(graphQLType)));
48+
this.path = path;
49+
}
50+
4551
public NonNullableValueCoercedAsNullException(GraphQLInputObjectField inputTypeField) {
4652
super(format("Input field '%s' has coerced Null value for NonNull type '%s'",
4753
inputTypeField.getName(), GraphQLTypeUtil.simplePrint(inputTypeField.getType())));

0 commit comments

Comments
 (0)