o
    tBhi                     @   sT  d dl mZmZmZmZmZmZmZ ddlm	Z	 ddl
mZmZmZmZmZ ddlmZ ddlmZmZmZ dgZG d	d deZejejejd
Zi dejdejdejdejdej dej!dej!dej"dej"dej#dej#dej$dej%dej%dej&dej&dej'ej'ej(ej)ej)dZ*dee dee fdd Z+d!S )"    )castAnyDictListOptionalTupleUnion   )GraphQLError)DirectiveLocationDirectiveDefinitionNodeDirectiveNodeNodeOperationDefinitionNode)specified_directives   )ASTValidationRuleSDLValidationContextValidationContextKnownDirectivesRulec                       sf   e Zd ZU dZeeef ed< deeef f fddZde	de
de
de
d	ee d
dfddZ  ZS )r   zKnown directives

    A GraphQL document is only valid if all ``@directives`` are known by the schema and
    legally positioned.

    See https://spec.graphql.org/draft/#sec-Directives-Are-Defined
    contextc                    s   t  | i }|j}|r|jnttt}|D ]}|j||j< q|j	j
}|D ]}t|tr;tdd |jD ||jj< q&|| _d S )Nc                 s   s    | ]}t |j V  qd S )N)r   value).0name r   /var/www/html/riverr-enterprise-integrations-main/venv/lib/python3.10/site-packages/graphql/validation/rules/known_directives.py	<genexpr>)   s    

z/KnownDirectivesRule.__init__.<locals>.<genexpr>)super__init__schema
directivesr   r   r   	locationsr   documentdefinitions
isinstancer   tupler   locations_map)selfr   r&   r   defined_directives	directiveast_definitionsdef_	__class__r   r   r      s   

zKnownDirectivesRule.__init__node_key_parent_path	ancestorsreturnNc           	      C   st   |j j}| j|}|r,t|}|r(||vr*| td| d|j d| d S d S d S | td| d| d S )NzDirective '@z' may not be used on .zUnknown directive '@z'.)r   r   r&   get#get_directive_location_for_ast_pathreport_errorr
   )	r'   r.   r/   r0   r1   r2   r   r!   candidate_locationr   r   r   enter_directive.   s   	z#KnownDirectivesRule.enter_directive)__name__
__module____qualname____doc__r   r   r   __annotations__r   r   r   r   r   r9   __classcell__r   r   r,   r   r      s"   
 )querymutationsubscriptionfieldfragment_spreadinline_fragmentfragment_definitionvariable_definitionschema_definitionschema_extensionscalar_type_definitionscalar_type_extensionobject_type_definitionobject_type_extensionfield_definitioninterface_type_definitioninterface_type_extensionunion_type_definitionunion_type_extensionenum_type_definition)enum_type_extensionenum_value_definitioninput_object_type_definitioninput_object_type_extensionr2   r3   c                 C   sn   | d }t |tstd|j}|dkrtt|}t|jj S |dkr2| d }|jdkr/t	j
S t	jS t|S )NzUnexpected error in directive.operation_definitioninput_value_definitionrV   )r$   r   	TypeErrorkindr   r   _operation_location	operationr   r   INPUT_FIELD_DEFINITIONARGUMENT_DEFINITION_directive_locationr5   )r2   
applied_tor]   parent_noder   r   r   r6   e   s   



r6   N),typingr   r   r   r   r   r   r   errorr
   languager   r   r   r   r   typer    r   r   r   __all__r   QUERYMUTATIONSUBSCRIPTIONr^   FIELDFRAGMENT_SPREADINLINE_FRAGMENTFRAGMENT_DEFINITIONVARIABLE_DEFINITIONSCHEMASCALAROBJECTFIELD_DEFINITION	INTERFACEUNIONENUM
ENUM_VALUEINPUT_OBJECTrb   r6   r   r   r   r   <module>   sp   $ 6	
