
    lh                        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 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 Z$d Z%ed        Z&y# e$ r	  ed      w xY w)    )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        Zy)GrapheneIntegrationgraphenec                  N    t        d      } t        t        |        t                y )Nr   )r   r   r   _patch_graphql)versions    r/var/www/pru.catia.catastroantioquia-mas.com/tasa/lib/python3.12/site-packages/sentry_sdk/integrations/graphene.py
setup_oncezGrapheneIntegration.setup_once!   s     "*-2G<    N)__name__
__module____qualname__
identifierstaticmethodr    r   r   r   r      s    J r   r   c                      t         j                  t         j                  t        t              fd       } fd}| t         _        |t         _        y )Nc           	         t        j                         }|j                  t               t	        | ||      5   
| |g|i |}d d d        t               5  t        j                         }j                  xs g D ]E  }t        ||j                  t        j                  dd      \  }}	t        j                  ||	       G 	 d d d        |S # 1 sw Y   xY w# 1 sw Y   S xY w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   sourceargskwargsscoperesultclienterroreventr-   old_graphql_syncs             r   _sentry_patched_graphql_syncz4_patch_graphql.<locals>._sentry_patched_graphql_sync/   s     ..0!!"23&&&1 	G%ffFtFvFF	G )* 	;**,F," 	;2#)>> 3 > >#(t ((T:	;	; !	G 	G	; s   CA-CCC&c           	      n  K   t        j                         j                  t              }| | |g|i | d {   S t        j                         }|j                  t               t        | ||      5   | |g|i | d {   }d d d        t               5  t        j                         }j                  xs g D ]E  }t        ||j                  t        j                  dd      \  }	}
t        j                  |	|
       G 	 d d d        |S 7 7 # 1 sw Y   xY w# 1 sw Y   S xY wwr(   )r.   r3   get_integrationr   r/   r0   r1   r2   r	   r4   r   r5   r#   r6   )r   r7   r8   r9   integrationr:   r;   r<   r=   r>   r-   old_graphql_asyncs              r   _sentry_patched_graphql_asyncz5_patch_graphql.<locals>._sentry_patched_graphql_asyncG   s0     ++-==>QR*66KDKFKKK..0!!"23&&&1 	N,VVMdMfMMF	N )* 	;**,F," 	;2#)>> 3 > >#(t ((T:	;	; + L N	N 	N	; sR   :D5D:D58D	D
DD5 A-D(D5DD%!D5(D2-D5)graphene_schemagraphql_syncgraphqlr
   r   )r@   rE   rD   r?   s     @@r   r   r   *   sO    &33'// 35EF G.6 $@O ;Or   c                     t               r| j                  di       }d|d<   | S | j                  di       j                  d      r| d   d= | S )NrequestrH   
api_targetdata)r   
setdefaultget)r>   r-   request_infos      r   r1   r1   f   sX     ''	26%.\"
 L 
9b	!	%	%f	-)V$Lr   c              #     K   |j                  d      }d}t        j                  }|j                         j	                  d      rd}t        j
                  }n1|j                         j	                  d      rd}t        j                  }t        j                  ||ddd       t        j                         }|j                  r|j                  j                  ||	      }nt        j                  ||	      }|j                  d
|       |j                  d|       |j                  d|       	 d  |j                          y # |j                          w xY ww)Noperation_namequerymutationsubscription)rQ   operation_typezgraphql.operation)rL   category)crumb)opnamezgraphql.documentzgraphql.operation.namezgraphql.operation.type)rN   r   GRAPHQL_QUERYstrip
startswithGRAPHQL_MUTATIONGRAPHQL_SUBSCRIPTIONr.   add_breadcrumbget_current_scopespanstart_child
start_spanset_datafinish)r   r7   r9   rQ   rU   rX   r:   _graphql_spans           r   r2   r2   r   s)     ZZ 01NN			B||~  ,#  		"	">	2'$$ #1"0 ,
 ((*Ezz

..">.J"--.I-v63^D3^Ds   D.E1E 5EEE)'
contextlibr   r.   sentry_sdk.constsr   sentry_sdk.integrationsr   r   r   sentry_sdk.scoper   sentry_sdk.utilsr	   r
   r   r   graphene.typesr   rF   ImportErrortypingr   collections.abcr   r   r   r   graphene.language.sourcer   graphql.executionr   graphql.typer   sentry_sdk._typesr   r   r   r1   r2   r%   r   r   <module>rt      s    %    U U 4 48 !)''/1*'	+ 	9<x	 $ $G  4
2
334s   A> >B