o
    tBhO                     @   sZ   d dl mZmZmZ ddlmZ ddlmZmZ ddl	m
Z
mZ dgZG dd deZd	S )
    )AnyListSet   )GraphQLError)OperationDefinitionNodeVariableDefinitionNode   )ValidationContextValidationRuleNoUnusedVariablesRulec                       sd   e Zd ZdZdef fddZdeddfdd	Zd
ededdfddZ	de
deddfddZ  ZS )r   zNo unused variables

    A GraphQL operation is only valid if all variables defined by an operation are used,
    either directly or within a spread fragment.

    See https://spec.graphql.org/draft/#sec-All-Variables-Used
    contextc                    s   t  | g | _d S N)super__init__variable_defs)selfr   	__class__ /var/www/html/riverr-enterprise-integrations-main/venv/lib/python3.10/site-packages/graphql/validation/rules/no_unused_variables.pyr      s   
zNoUnusedVariablesRule.__init___argsreturnNc                 G   s   | j   d S r   )r   clear)r   r   r   r   r   enter_operation_definition   s   z0NoUnusedVariablesRule.enter_operation_definition	operationc              	   G   s   t  }| j|}|D ]
}||jjj q| jD ]%}|jjj}||vr>| 	t
|jr5d| d|jj dnd| d| qd S )NzVariable '$z' is never used in operation 'z'.z' is never used.)setr   get_recursive_variable_usagesaddnodenamevaluer   variablereport_errorr   )r   r   r   variable_name_usedusagesusagevariable_defvariable_namer   r   r   leave_operation_definition   s&   



z0NoUnusedVariablesRule.leave_operation_definition
definitionc                 G   s   | j | d S r   )r   append)r   r*   r   r   r   r   enter_variable_definition2   s   z/NoUnusedVariablesRule.enter_variable_definition)__name__
__module____qualname____doc__r
   r   r   r   r   r)   r   r,   __classcell__r   r   r   r   r   
   s$    
N)typingr   r   r   errorr   languager   r    r
   r   __all__r   r   r   r   r   <module>   s    