Skip to content

Commit

Permalink
debug entering
Browse files Browse the repository at this point in the history
  • Loading branch information
JerrySentry committed Nov 18, 2024
1 parent d984c41 commit 2179a38
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions graphql_api/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,17 @@ def __init__(self, context: ValidationContext) -> None:
def enter_operation_definition(
self, node: OperationDefinitionNode, *_args: Any
) -> None:
print("entering RequiredVariablesValidationRule")

# Get variable definitions
variable_definitions = node.variable_definitions or []

print(
"var defs",
variable_definitions,
[(v.variable.name.value, v.type.kind) for v in variable_definitions],
)

# Extract variables marked as Non Null
required_variables = [
var_def.variable.name.value
Expand All @@ -30,12 +38,17 @@ def enter_operation_definition(
and var_def.type.kind == "non_null_type"
]

print("required_variables", required_variables)

# Check if these required variables are provided
provided_variables = self.variables

print("provided_variables", provided_variables)

missing_variables = [
var for var in required_variables if var not in provided_variables
]
print("missing_variables", missing_variables)
if missing_variables:
raise GraphQLError(
f"Missing required variables: {', '.join(missing_variables)}",
Expand Down

0 comments on commit 2179a38

Please sign in to comment.