o
    ÑtBhS  ã                   @   s¦  d dl mZmZmZmZmZmZ ddlmZm	Z	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	gZd
edeee	f deeef dededeeee f fdd„Zd
edeee	f deeef dedee deeee f fdd	„Zd
edeee	f deeef dededeeee f dee ddfdd„Zdeeef dee
eef defdd„Zd
edee	ef dedefdd„Zdedefd d!„Z dS )"é    )ÚAnyÚDictÚListÚSetÚUnionÚcasté   )Ú	FieldNodeÚFragmentDefinitionNodeÚFragmentSpreadNodeÚInlineFragmentNodeÚSelectionSetNode)ÚGraphQLAbstractTypeÚGraphQLIncludeDirectiveÚGraphQLObjectTypeÚGraphQLSchemaÚGraphQLSkipDirectiveÚis_abstract_type)Útype_from_asté   )Úget_directive_valuesÚcollect_fieldsÚcollect_sub_fieldsÚschemaÚ	fragmentsÚvariable_valuesÚruntime_typeÚselection_setÚreturnc                 C   s   i }t | |||||tƒ ƒ |S )a;  Collect fields.

    Given a selection_set, collects all the fields and returns them.

    collect_fields requires the "runtime type" of an object. For a field that
    returns an Interface or Union type, the "runtime type" will be the actual
    object type returned by that field.

    For internal use only.
    )Úcollect_fields_implÚset)r   r   r   r   r   Úfields© r"   úw/var/www/html/riverr-enterprise-integrations-main/venv/lib/python3.10/site-packages/graphql/execution/collect_fields.pyr      s
   ÿÚreturn_typeÚfield_nodesc              	   C   s4   i }t ƒ }|D ]}|jrt| ||||j||ƒ q|S )ar  Collect sub fields.

    Given a list of field nodes, collects all the subfields of the passed in fields,
    and returns them at the end.

    collect_sub_fields requires the "return type" of an object. For a field that
    returns an Interface or Union type, the "return type" will be the actual
    object type returned by that field.

    For internal use only.
    )r    r   r   )r   r   r   r$   r%   Úsub_field_nodesÚvisited_fragment_namesÚnoder"   r"   r#   r   0   s   ù€	r!   r'   Nc              	   C   sÞ   |j D ]i}t|tƒrt||ƒsqt|ƒ}| |g ¡ |¡ qt|tƒr;t||ƒr.t| ||ƒs/qt	| ||||j
||ƒ qt|tƒrl|jj}	|	|v sMt||ƒsNq| |	¡ | |	¡}
|
r`t| |
|ƒsaqt	| ||||
j
||ƒ qdS )z)Collect fields (internal implementation).N)Ú
selectionsÚ
isinstancer	   Úshould_include_nodeÚget_field_entry_keyÚ
setdefaultÚappendr   Údoes_fragment_condition_matchr   r   r   ÚnameÚvalueÚaddÚget)r   r   r   r   r   r!   r'   Ú	selectionr0   Ú	frag_nameÚfragmentr"   r"   r#   r   R   sZ   




ÿ
þù
	
ÿ

ÿù€àr   r(   c                 C   s<   t t|| ƒ}|r|d rdS t t|| ƒ}|r|d sdS dS )z´Check if node should be included

    Determines if a field should be included based on the @include and @skip
    directives, where @skip has higher precedence than @include.
    ÚifFT)r   r   r   )r   r(   ÚskipÚincluder"   r"   r#   r+   ‡   s   	r+   r6   Útype_c                 C   sB   |j }|sdS t| |ƒ}||u rdS t|ƒr|  tt|ƒ|¡S dS )z8Determine if a fragment is applicable to the given type.TF)Útype_conditionr   r   Úis_sub_typer   r   )r   r6   r:   Útype_condition_nodeÚconditional_typer"   r"   r#   r/   ›   s   
r/   c                 C   s   | j r| j jS | jjS )z@Implements the logic to compute the key of a given field's entry)Úaliasr1   r0   )r(   r"   r"   r#   r,   ¬   s   r,   )!Útypingr   r   r   r   r   r   Úlanguager	   r
   r   r   r   Útyper   r   r   r   r   r   Úutilities.type_from_astr   Úvaluesr   Ú__all__Ústrr   r   r   Úboolr+   r/   r,   r"   r"   r"   r#   Ú<module>   s„      ÿ
þ
ýüû
úÿ
þ
ýüû
ú"ÿ
þ
ýüûúù
ø5
ÿþ
ýÿ
þý
ü