Skip to content

Commit e06b358

Browse files
committed
Merge pull request #37 from jhgg/arguments-of-correct-type
Implementation of ArgumentOfCorrectType & tests
2 parents 4c41069 + f24bdd9 commit e06b358

File tree

2 files changed

+684
-1
lines changed

2 files changed

+684
-1
lines changed

graphql/core/validation/rules.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,18 @@ def duplicate_arg_message(field):
511511

512512

513513
class ArgumentsOfCorrectType(ValidationRule):
514-
pass
514+
def enter_Argument(self, node, *args):
515+
arg_def = self.context.get_argument()
516+
if arg_def and not is_valid_literal_value(arg_def.type, node.value):
517+
return GraphQLError(
518+
self.bad_value_message(node.name.value, arg_def.type,
519+
print_ast(node.value)),
520+
[node.value]
521+
)
522+
523+
@staticmethod
524+
def bad_value_message(arg_name, type, value):
525+
return 'Argument "{}" expected type "{}" but got: {}.'.format(arg_name, type, value)
515526

516527

517528
class ProvidedNonNullArguments(ValidationRule):

0 commit comments

Comments
 (0)