o
    tBh!                     @   s  d dl mZ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mZmZmZmZmZmZmZmZmZ ddlmZmZmZ ddlmZm Z m!Z!m"Z"m#Z#m$Z$ ddl%m&Z& ddl'm(Z( dd	l)m*Z* g d
Z+eee
 ee,ef f Z-	dde"dee dee,ef dee. de-f
ddZ/de"dee dee,ef dee
gdf dee,ef f
ddZ0	ddee ef deeef deee,ef  dee,ef fddZ1eeeeeeeeef Z2	ddede2deee,ef  deee,ef  fddZ3dS )    )AnyCallable
CollectionDictListOptionalUnioncast   )GraphQLError)DirectiveNodeEnumValueDefinitionNodeExecutableDefinitionNodeFieldDefinitionNode	FieldNodeInputValueDefinitionNodeNullValueNodeSchemaDefinitionNodeSelectionNodeTypeDefinitionNodeTypeExtensionNodeVariableDefinitionNodeVariableNode	print_ast)	Undefinedinspectprint_path_list)GraphQLDirectiveGraphQLFieldGraphQLInputTypeGraphQLSchemais_input_typeis_non_null_type)coerce_input_value)type_from_ast)value_from_ast)get_argument_valuesget_directive_valuesget_variable_valuesNschemavar_def_nodesinputs
max_errorsreturnc              
      sl   g  dt ddf fdd}zt| |||} s|W S W  S  t y5 } z | W Y d}~ S d}~ww )a#  Get coerced variable values based on provided definitions.

    Prepares a dict of variable values of the correct type based on the provided
    variable definitions and arbitrary input. If the input cannot be parsed to match
    the variable definitions, a GraphQLError will be raised.
    errorr-   Nc                    s*   d urt  krtd |  d S )NzMToo many errors processing variables, error limit reached. Execution aborted.)lenr   append)r.   errorsr,    o/var/www/html/riverr-enterprise-integrations-main/venv/lib/python3.10/site-packages/graphql/execution/values.pyon_error5   s
   z%get_variable_values.<locals>.on_error)r   coerce_variable_valuesr0   )r)   r*   r+   r,   r5   coerceder3   r1   r4   r(   '   s   r(   r5   c           	   	      s.  i }|D ]j jjt| j}t|s*tj} td d| dj qtt	|}|vrVj
r?tj
||< nt|rUt|} td d| d q| }|d u rut|rut|} td d| d qdttttf  d	td
tdd f fdd}t||||< q|S )NVariable '$z' expected value of type 'z(' which cannot be used as an input type.' of required type '' was not provided.' of non-null type '' must not be null.pathinvalid_valuer.   r-   c                    sT   t |}d d| }| r|d t|  d7 } t|d |j |d d S )Nr9   z' got invalid value z at ''z; )original_error)r   r   r   message)r>   r?   r.   invalid_strprefixr5   var_def_nodevar_namer3   r4   on_input_value_error{   s   z4coerce_variable_values.<locals>.on_input_value_error)variablenamevaluer$   typer!   r   r   r	   r   default_valuer%   r"   r   r   r   strintr   r#   )	r)   r*   r+   r5   coerced_valuesvar_typevar_type_strrK   rH   r3   rE   r4   r6   G   sf   




r6   type_defnodevariable_valuesc              	   C   sl  i }dd |j p	g D }| j D ]\}}|j}||}|du r@|jtur/|j||jp-|< nt|r?t	d| d| d|q|j
}	t|j
t}
t|	tr|	jj
}|du sZ||vr||jturh|j||jpf|< nt|r{t	d| d| d| d|	q|| du }
|
rt|rt	d| d	| d
|	t|	||}|tu rt	d| dt|	 d|	|||jp|< q|S )zGet coerced argument values based on provided definitions and nodes.

    Prepares a dict of argument values given a list of argument definitions and list
    of argument AST nodes.
    c                 S   s   i | ]}|j j|qS r3   )rJ   rK   ).0argr3   r3   r4   
<dictcomp>   s    z'get_argument_values.<locals>.<dictcomp>Nz
Argument 'r:   r;   z' was provided the variable '$z)' which was not provided a runtime value.r<   r=   z' has invalid value .)	argumentsargsitemsrL   getrM   r   out_namer"   r   rK   
isinstancer   r   rJ   r%   r   )rS   rT   rU   rP   arg_node_maprJ   arg_defarg_typeargument_node
value_nodeis_nullvariable_namecoerced_valuer3   r3   r4   r&      sV   




r&   directive_defc                 C   s:   |j }|r| j}|D ]}|jj|krt| ||  S q
dS )a#  Get coerced argument values based on provided nodes.

    Prepares a dict of argument values given a directive definition and an AST node
    which may contain directives. Optionally also accepts a dict of variable values.

    If the directive does not exist on the node, returns None.
    N)
directivesrJ   rK   r&   )rh   rT   rU   ri   directive_name	directiver3   r3   r4   r'      s   r'   )N)4typingr   r   r   r   r   r   r   r	   r.   r   languager   r   r   r   r   r   r   r   r   r   r   r   r   r   pyutilsr   r   r   rL   r   r   r   r    r!   r"   utilities.coerce_input_valuer#   utilities.type_from_astr$   utilities.value_from_astr%   __all__rN   CoercedVariableValuesrO   r(   r6   r&   NodeWithDirectiver'   r3   r3   r3   r4   <module>   s   ( @ 

 


M



B