
    $g                     \    d dl mZ d dlmZmZ d dlmZ d dlmZ  G d de          Z	dgZ
dS )    )	lru_cache)IteratorOptional)SchemaExtension)parse_documentc                   H    e Zd ZdZddee         ddfdZded         fdZdS )ParserCachea7  Add LRU caching the parsing step during execution to improve performance.

    Example:

    ```python
    import strawberry
    from strawberry.extensions import ParserCache

    schema = strawberry.Schema(
        Query,
        extensions=[
            ParserCache(maxsize=100),
        ],
    )
    ```
    Nmaxsizereturnc                 L     t          |          t                    | _        dS )a  Initialize the ParserCache.

        Args:
            maxsize: Set the maxsize of the cache. If `maxsize` is set to `None` then the
                cache will grow without bound.
                More info: https://docs.python.org/3/library/functools.html#functools.lru_cache
        )r
   N)r   r   cached_parse_document)selfr
   s     b/var/www/html/netbox-4.1.3/venv/lib/python3.11/site-packages/strawberry/extensions/parser_cache.py__init__zParserCache.__init__   s(     &@Yw%?%?%?%O%O"""    c              #   Z   K   | j         } | j        |j        fi |j        |_        d V  d S N)execution_contextr   queryparse_optionsgraphql_document)r   r   s     r   on_parsezParserCache.on_parse$   sL       2-GT-G#.
 .
'8'F.
 .
* 	r   r   )	__name__
__module____qualname____doc__r   intr   r   r    r   r   r	   r	      so         "P P P P P P P(4.      r   r	   N)	functoolsr   typingr   r   $strawberry.extensions.base_extensionr   strawberry.schema.executer   r	   __all__r   r   r   <module>r$      s          % % % % % % % % @ @ @ @ @ @ 4 4 4 4 4 4" " " " "/ " " "J /r   