o
    Zh                     @   s   d dl mZmZ d dlmZmZ d dlmZmZm	Z	 d dl
mZ zd dlmZ W n ey3   edw erXd dlmZmZmZ d dlmZ d d	lmZ d d
lmZ d dl
mZ G dd deZdd Zdd ZdS )    )Hub_should_send_default_pii)DidNotEnableIntegration)capture_internal_exceptionsevent_from_exceptionpackage_version)TYPE_CHECKING)schemazgraphene is not installed)AnyDictUnion)Source)ExecutionResult)GraphQLSchema)Eventc                   @   s   e Zd ZdZedd ZdS )GrapheneIntegrationgraphenec                  C   s2   t d} | d u rtd| dk rtdt  d S )Nr   zUnparsable graphene version.)   r   zgraphene 3.3 or newer required.)r   r   _patch_graphql)version r   W/var/www/html/lang_env/lib/python3.10/site-packages/sentry_sdk/integrations/graphene.py
setup_once   s   
zGrapheneIntegration.setup_onceN)__name__
__module____qualname__
identifierstaticmethodr   r   r   r   r   r      s    r   c                     s4   t jt j fdd}  fdd}| t _|t _d S )Nc                    s   t j}|t}|d u r | |g|R i |S | }|t W d    n1 s,w   Y   | |g|R i |}t , |jpEg D ]}t	||j
rQ|j
jnd |jddd\}	}
|j|	|
d qFW d    |S 1 sow   Y  |S NF)typeZhandled)Zclient_optionsZ	mechanism)hintr   currentZget_integrationr   Zconfigure_scopeZadd_event_processor_event_processorr   errorsr   clientoptionsr   Zcapture_eventr
   sourceargskwargsZhubZintegrationscoperesulterroreventr!   )old_graphql_syncr   r   _sentry_patched_graphql_sync/   s.   



z4_patch_graphql.<locals>._sentry_patched_graphql_syncc                    s   t j}|t}|d u r | |g|R i |I d H S | }|t W d    n1 s0w   Y   | |g|R i |I d H }t , |jpLg D ]}t	||j
rX|j
jnd |jddd\}	}
|j|	|
d qMW d    |S 1 svw   Y  |S r   r"   r(   )old_graphql_asyncr   r   _sentry_patched_graphql_asyncI   s0   



z5_patch_graphql.<locals>._sentry_patched_graphql_async)graphene_schemaZgraphql_syncgraphql)r1   r3   r   )r2   r0   r   r   *   s   
r   c                 C   s>   t  r| di }d|d< | S | di dr| d d= | S )Nrequestr5   Z
api_targetdata)r   
setdefaultget)r/   r!   Zrequest_infor   r   r   r$   g   s   
r$   N)Zsentry_sdk.hubr   r   Zsentry_sdk.integrationsr   r   Zsentry_sdk.utilsr   r   r   Zsentry_sdk._typesr	   Zgraphene.typesr
   r4   ImportErrortypingr   r   r   Zgraphene.language.sourcer   Zgraphql.executionr   Zgraphql.typer   r   r   r   r$   r   r   r   r   <module>   s$    =