o
    tBh                     @   s^   d dl mZmZ ddlmZ ddlmZmZmZm	Z	 ddl
mZmZ dgZG dd deZd	S )
    )AnyList   )GraphQLError)FragmentDefinitionNodeOperationDefinitionNodeVisitorActionSKIP   )ASTValidationContextASTValidationRuleNoUnusedFragmentsRulec                       sd   e Zd ZdZdef fddZdededefdd	Z	de
dedefd
dZdeddfddZ  ZS )r   zNo unused fragments

    A GraphQL document is only valid if all fragment definitions are spread within
    operations, or spread within other fragments spread within operations.

    See https://spec.graphql.org/draft/#sec-Fragments-Must-Be-Used
    contextc                    s   t  | g | _g | _d S N)super__init__operation_defsfragment_defs)selfr   	__class__ /var/www/html/riverr-enterprise-integrations-main/venv/lib/python3.10/site-packages/graphql/validation/rules/no_unused_fragments.pyr      s   
zNoUnusedFragmentsRule.__init__node_argsreturnc                 G      | j | tS r   )r   appendr	   r   r   r   r   r   r   enter_operation_definition      z0NoUnusedFragmentsRule.enter_operation_definitionc                 G   r   r   )r   r   r	   r   r   r   r   enter_fragment_definition#   r    z/NoUnusedFragmentsRule.enter_fragment_definitionNc                 G   sn   t  }| jj}| jD ]}||D ]	}||jj qq
| jD ]}|jj}||vr4| t	d| d| qd S )Nz
Fragment 'z' is never used.)
setr   $get_recursively_referenced_fragmentsr   addnamevaluer   report_errorr   )r   r   fragment_names_usedget_fragments	operationfragmentfragment_def	frag_namer   r   r   leave_document)   s   

z$NoUnusedFragmentsRule.leave_document)__name__
__module____qualname____doc__r   r   r   r   r   r   r   r!   r.   __classcell__r   r   r   r   r      s$    

N)typingr   r   errorr   languager   r   r   r	    r   r   __all__r   r   r   r   r   <module>   s    