File tree 1 file changed +40
-0
lines changed
1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change 1
1
from functools import partial
2
2
3
+ from graphql .pyutils import Undefined
4
+ from graphql .type import (
5
+ GraphQLArgument ,
6
+ GraphQLField ,
7
+ GraphQLObjectType ,
8
+ GraphQLSchema ,
9
+ GraphQLScalarType ,
10
+ GraphQLString ,
11
+ )
3
12
from graphql .validation import ValuesOfCorrectTypeRule
4
13
5
14
from .harness import assert_validation_errors
@@ -1022,6 +1031,37 @@ def reports_original_error_for_custom_scalar_which_throws():
1022
1031
"Invalid scalar is always invalid: 123"
1023
1032
)
1024
1033
1034
+ def reports_error_for_custom_scalar_that_returns_undefined ():
1035
+ custom_scalar = GraphQLScalarType (
1036
+ "CustomScalar" , parse_value = lambda value : Undefined
1037
+ )
1038
+
1039
+ schema = GraphQLSchema (
1040
+ GraphQLObjectType (
1041
+ "Query" ,
1042
+ {
1043
+ "invalidArg" : GraphQLField (
1044
+ GraphQLString , args = {"arg" : GraphQLArgument (custom_scalar )}
1045
+ )
1046
+ },
1047
+ )
1048
+ )
1049
+
1050
+ assert_errors (
1051
+ """
1052
+ {
1053
+ invalidArg(arg: 123)
1054
+ }
1055
+ """ ,
1056
+ [
1057
+ {
1058
+ "message" : "Expected value of type 'CustomScalar', found 123." ,
1059
+ "locations" : [(3 , 35 )],
1060
+ },
1061
+ ],
1062
+ schema = schema ,
1063
+ )
1064
+
1025
1065
def allows_custom_scalar_to_accept_complex_literals ():
1026
1066
assert_valid (
1027
1067
"""
You can’t perform that action at this time.
0 commit comments