Skip to content

Commit de781eb

Browse files
committed
Update scalar coercion example
1 parent 5a0fb3d commit de781eb

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

src/test/groovy/readme/ScalarExamples.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
package readme;
22

3+
import graphql.GraphQLContext;
4+
import graphql.execution.CoercedVariables;
35
import graphql.language.StringValue;
6+
import graphql.language.Value;
47
import graphql.schema.Coercing;
58
import graphql.schema.CoercingParseLiteralException;
69
import graphql.schema.CoercingParseValueException;
710
import graphql.schema.CoercingSerializeException;
811
import graphql.schema.GraphQLScalarType;
12+
import org.jetbrains.annotations.NotNull;
913

14+
import java.util.Locale;
1015
import java.util.regex.Pattern;
1116

1217
@SuppressWarnings("unused")
@@ -19,17 +24,17 @@ public static class EmailScalar {
1924
.description("A custom scalar that handles emails")
2025
.coercing(new Coercing() {
2126
@Override
22-
public Object serialize(Object dataFetcherResult) {
27+
public Object serialize(@NotNull Object dataFetcherResult, @NotNull GraphQLContext graphQLContext, @NotNull Locale locale) {
2328
return serializeEmail(dataFetcherResult);
2429
}
2530

2631
@Override
27-
public Object parseValue(Object input) {
32+
public Object parseValue(@NotNull Object input, @NotNull GraphQLContext graphQLContext, @NotNull Locale locale) {
2833
return parseEmailFromVariable(input);
2934
}
3035

3136
@Override
32-
public Object parseLiteral(Object input) {
37+
public Object parseLiteral(@NotNull Value input, @NotNull CoercedVariables variables, @NotNull GraphQLContext graphQLContext, @NotNull Locale locale) {
3338
return parseEmailFromAstLiteral(input);
3439
}
3540
})
@@ -73,5 +78,4 @@ private static Object parseEmailFromAstLiteral(Object input) {
7378
}
7479
}
7580

76-
7781
}

0 commit comments

Comments
 (0)