File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change 11from functools import partial
22
3+ from graphql .pyutils import Undefined
4+ from graphql .type import (
5+ GraphQLArgument ,
6+ GraphQLField ,
7+ GraphQLObjectType ,
8+ GraphQLSchema ,
9+ GraphQLScalarType ,
10+ GraphQLString ,
11+ )
312from graphql .validation import ValuesOfCorrectTypeRule
413
514from .harness import assert_validation_errors
@@ -1022,6 +1031,37 @@ def reports_original_error_for_custom_scalar_which_throws():
10221031 "Invalid scalar is always invalid: 123"
10231032 )
10241033
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+
10251065 def allows_custom_scalar_to_accept_complex_literals ():
10261066 assert_valid (
10271067 """
You can’t perform that action at this time.
0 commit comments