
    tni                     J   d dl mZ d dlZd dlmZ d dlmZmZmZ d dl	m
Z
 d dlmZmZmZmZ 	 d dlmZ n# e$ r  ed          w xY wd d	lmZ er(d d
lmZ d 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e          Z#d dZ$d!dZ%e	 	 	 	 	 	 	 	 d"d            Z&dS )#    )contextmanagerN)OP)_check_minimum_versionDidNotEnableIntegration)should_send_default_pii)capture_internal_exceptionsensure_integration_enabledevent_from_exceptionpackage_version)schemazgraphene is not installed)TYPE_CHECKING)	Generator)AnyDictUnion)Source)ExecutionResult)GraphQLSchema)Eventc                   *    e Zd ZdZedd            ZdS )GrapheneIntegrationgraphenereturnNc                  j    t          d          } t          t          |            t                       d S )Nr   )r   r   r   _patch_graphql)versions    ]/var/www/html/gpu-tools/venv/lib/python3.11/site-packages/sentry_sdk/integrations/graphene.py
setup_oncezGrapheneIntegration.setup_once!   s2    !*--2G<<<    r   N)__name__
__module____qualname__
identifierstaticmethodr    r    r   r   r      s7        J   \  r    r   r   c                      t           j        t           j        t          t                    	 	 	 	 	 	 	 	 	 	 dfd
            } 	 	 	 	 	 	 	 	 	 	 dfd}| t           _        |t           _        d S )Nr   r   sourceUnion[str, Source]argsr   kwargsr   r   c           	         t          j                    }|                    t                     t	          | ||          5   
| |g|R i |}d d d            n# 1 swxY w Y   t                      5  t          j                    }|j        pg D ]?}t          ||j	        t          j        dd          \  }}	t          j        ||	           @	 d d d            n# 1 swxY w Y   |S NF)typehandled)client_options	mechanism)hint)
sentry_sdkget_isolation_scopeadd_event_processor_event_processorgraphql_spanr	   
get_clienterrorsr   optionsr   r%   capture_event)r   r)   r+   r,   scoperesultclienterroreventr3   old_graphql_syncs             r   _sentry_patched_graphql_syncz4_patch_graphql.<locals>._sentry_patched_graphql_sync-   s    .00!!"2333&&&11 	G 	G%%ffFtFFFvFFF	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G )** 	; 	;*,,F," 	; 	;2#)> 3 >#(   t (T:::::	;	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; s%    AA!A3ACC!$C!c           	      d  K   t          j                                        t                    }| | |g|R i | d {V S t          j                    }|                    t                     t          | ||          5   | |g|R i | d {V }d d d            n# 1 swxY w Y   t                      5  t          j                    }|j	        pg D ]?}t          ||j        t          j        dd          \  }	}
t          j        |	|
           @	 d d d            n# 1 swxY w Y   |S r.   )r4   r9   get_integrationr   r5   r6   r7   r8   r	   r:   r   r;   r%   r<   )r   r)   r+   r,   integrationr=   r>   r?   r@   rA   r3   old_graphql_asyncs              r   _sentry_patched_graphql_asyncz5_patch_graphql.<locals>._sentry_patched_graphql_asyncI   s      !+--==>QRR**66KDKKKFKKKKKKKKK.00!!"2333&&&11 	N 	N,,VVMdMMMfMMMMMMMMF	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N )** 	; 	;*,,F," 	; 	;2#)> 3 >#(   t (T:::::	;	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; s%   B""B&)B&;AD%%D),D))
r   r   r)   r*   r+   r   r,   r   r   r   )graphene_schemagraphql_syncgraphqlr
   r   )rC   rH   rG   rB   s     @@r   r   r   )   s    &3'/ 35EFF$  	
 
     GF6$  	
 
     > $@O ;Or    rA   r   r3   Dict[str, Any]c                     t                      r|                     di           }d|d<   n2|                     di                               d          r	| d         d= | S )NrequestrK   
api_targetdata)r   
setdefaultget)rA   r3   request_infos      r   r7   r7   l   sh       %''	266%.\""	9b	!	!	%	%f	-	- %)V$Lr    r   r   r)   r*   r,   Generator[None, None, None]c              #     K   |                     d          }d}t          j        }|                                                    d          rd}t          j        }n5|                                                    d          rd}t          j        }t          j        ||ddd           t          j	                    }|j
        r|j
                            ||	          }nt          j        ||	          }|                    d
|           |                    d|           |                    d|           	 d V  |                                 d S # |                                 w xY w)Noperation_namequerymutationsubscription)rV   operation_typezgraphql.operation)rP   category)crumb)opnamezgraphql.documentzgraphql.operation.namezgraphql.operation.type)rR   r   GRAPHQL_QUERYstrip
startswithGRAPHQL_MUTATIONGRAPHQL_SUBSCRIPTIONr4   add_breadcrumbget_current_scopespanstart_child
start_spanset_datafinish)r   r)   r,   rV   rZ   r]   r=   _graphql_spans           r   r8   r8   w   s      ZZ 011NN		B||~~  ,, %# 		"	">	2	2 %'$ #1"0  ,
 
    (**Ez J
..">.JJ"-.III-v6663^DDD3^DDDs   <E E,r!   )rA   r   r3   rL   r   r   )r   r   r)   r*   r,   rL   r   rT   )'
contextlibr   r4   sentry_sdk.constsr   sentry_sdk.integrationsr   r   r   sentry_sdk.scoper   sentry_sdk.utilsr	   r
   r   r   graphene.typesr   rI   ImportErrortypingr   collections.abcr   r   r   r   graphene.language.sourcer   graphql.executionr   graphql.typer   sentry_sdk._typesr   r   r   r7   r8   r'   r    r   <module>ry      s   % % % % % %                 U U U U U U U U U U 4 4 4 4 4 4           48888888 4 4 4
,2
3
334 !           ())))))''''''''''//////111111******''''''    +   @< @< @< @<F    %%%9%CS%"% % % % % %s	   5 A