o
    tBh                     @   s   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mZmZ ddlmZmZ ddlmZ ddlmZmZmZ d	d
gZG dd
 d
eZG dd	 d	eZdS )    )castAnyDictListUnion   )GraphQLError)ArgumentNodeDirectiveDefinitionNodeDirectiveNodeSKIPVisitorAction)did_you_meansuggestion_list)specified_directives   )ASTValidationRuleSDLValidationContextValidationContextKnownArgumentNamesRule"KnownArgumentNamesOnDirectivesRulec                       sV   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fdd	Z  ZS )
r   zKnown argument names on directives

    A GraphQL directive is only valid if all supplied arguments are defined.

    For internal use only.
    contextc                    s   t  | i }|j}|r|jnt}tt|D ]
}t|j||j	< q|j
j}|D ]}t|tr=dd |jp6g D ||j	j< q(|| _d S )Nc                 S   s   g | ]}|j jqS  )namevalue).0argr   r   /var/www/html/riverr-enterprise-integrations-main/venv/lib/python3.10/site-packages/graphql/validation/rules/known_argument_names.py
<listcomp>(   s    z?KnownArgumentNamesOnDirectivesRule.__init__.<locals>.<listcomp>)super__init__schema
directivesr   r   r   listargsr   documentdefinitions
isinstancer
   	argumentsr   directive_args)selfr   r)   r!   defined_directives	directiveast_definitionsdef_	__class__r   r   r       s   

z+KnownArgumentNamesOnDirectivesRule.__init__directive_node_argsreturnc              	   G   sr   |j j}| j|}|jr7|d ur7|jD ]"}|j j}||vr6t||}| td| d| dt| | qt	S )NUnknown argument 'z' on directive '@'.)
r   r   r)   getr(   r   report_errorr   r   r   )r*   r1   r2   directive_name
known_argsarg_nodearg_namesuggestionsr   r   r   enter_directive.   s&   

z2KnownArgumentNamesOnDirectivesRule.enter_directive)__name__
__module____qualname____doc__r   r   r   __annotations__r    r   r   r   r=   __classcell__r   r   r/   r   r      s   
 c                       sF   e Zd ZU dZeed< def fddZdededdfd	d
Z	  Z
S )r   zKnown argument names

    A GraphQL field is only valid if all supplied arguments are defined by that field.

    See https://spec.graphql.org/draft/#sec-Argument-Names
    See https://spec.graphql.org/draft/#sec-Directives-Are-In-Valid-Locations
    r   c                    s   t  | d S )N)r   r    )r*   r   r/   r   r   r    N   s   zKnownArgumentNamesRule.__init__r:   r$   r3   Nc              
   G   s   | j }| }| }| }|sD|rF|rH|jj}|d d jj}t|j}	t||	}
|	t
d| d|j d| dt|
 | d S d S d S d S )Nr   r4   z' on field '.r5   )r   get_argumentget_field_defget_parent_typer   r   r#   r$   r   r7   r   r   )r*   r:   r$   r   arg_def	field_defparent_typer;   
field_nameknown_args_namesr<   r   r   r   enter_argumentQ   s,   

z%KnownArgumentNamesRule.enter_argument)r>   r?   r@   rA   r   rB   r    r	   r   rN   rC   r   r   r/   r   r   C   s
   
 N)typingr   r   r   r   r   errorr   languager	   r
   r   r   r   pyutilsr   r   typer    r   r   r   __all__r   r   r   r   r   r   <module>   s    1