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	m
Z
mZmZ dgZedef ZG dd dZde
edf dee fd	d
ZdS )    )partialreduce)
isfunction)CallableIteratorDictListTupleAnyOptionalMiddlewareManager.c                   @   sV   e Zd ZU dZdZeeef ed< ee	e
  ed< defddZded	efd
dZdS )r   a  Manager for the middleware chain.

    This class helps to wrap resolver functions with the provided middleware functions
    and/or objects. The functions take the next middleware function as first argument.
    If middleware is provided as an object, it must provide a method ``resolve`` that is
    used as the middleware function.

    Note that since resolvers return "AwaitableOrValue"s, all middleware functions
    must be aware of this and check whether values are awaitable before awaiting them.
    )__dict__middlewares_middleware_resolvers_cached_resolversr   r   r   c                 G   s&   || _ |rtt|nd | _i | _d S N)r   listget_middleware_resolversr   r   )selfr    r   s/var/www/html/riverr-enterprise-integrations-main/venv/lib/python3.10/site-packages/graphql/execution/middleware.py__init__   s   
zMiddlewareManager.__init__field_resolverreturnc                 C   s:   | j du r|S || jvrtdd | j || j|< | j| S )zWrap the provided resolver with the middleware.

        Returns a function that chains the middleware functions with the provided
        resolver function.
        Nc                 S   s
   t || S r   )r   )chained_fnsnext_fnr   r   r   <lambda>0   s   
 z6MiddlewareManager.get_field_resolver.<locals>.<lambda>)r   r   r   )r   r   r   r   r   get_field_resolver$   s   



z$MiddlewareManager.get_field_resolverN)__name__
__module____qualname____doc__	__slots__r   GraphQLFieldResolver__annotations__r   r   r   r
   r   r   r   r   r   r   r      s   
 r   r   c                 c   s:    | D ]}t |r|V  qt|dd}|dur|V  qdS )zEGet a list of resolver functions from a list of classes or functions.resolveN)r   getattr)r   
middlewareresolver_funcr   r   r   r   7   s   r   N)	functoolsr   r   inspectr   typingr   r   r   r   r	   r
   r   __all__r#   r   r   r   r   r   r   <module>   s    $",