U 췀g@s*ddlZddlmZmZmZddlmZmZddlm Z z@ddl Z ddl m Z m Z mZmZddlmZmZddlmZWnek redYnXdd lmZerdd lmZmZmZmZdd lmZmZeeeeeed fffZ d Z!GdddeZ"ddZ#ddZ$ddZ%ddZ&ddZ'dS)N)event_from_exceptionensure_integration_enabled parse_version) DidNotEnable Integration)should_send_default_pii) print_astget_operation_ast DocumentNodeVariableDefinitionNode) TransportAsyncTransport)TransportQueryErrorzgql is not installed) TYPE_CHECKING)AnyDictTupleUnion)EventEventProcessor.)c@seZdZdZeddZdS)GQLIntegrationgqlcCs@ttj}|dks|tkr6tddddtDtdS)Nz?GQLIntegration is only supported for GQL versions %s and above..css|]}t|VqdS)N)str).0numrI/opt/hc_python/lib/python3.8/site-packages/sentry_sdk/integrations/gql.py (sz,GQLIntegration.setup_once..)rr __version__MIN_GQL_VERSIONrjoin_patch_execute)Z gql_versionrrr setup_once!s zGQLIntegration.setup_onceN)__name__ __module__ __qualname__ identifier staticmethodr&rrrr rsrc CsfzBt|}dt|i}|dk r>|j|d<|jdk r>|jj|d<|WSttfk r`tYSXdS)Nquery variablesZ operationName)r rZvariable_definitionsnamevalueAttributeError TypeErrordict)documentZ operation_astdatarrr _data_from_document-s    r5cCs$z|jWStk rYdSXdS)zg The RequestsHTTPTransport allows defining the HTTP method; all other transports use POST. POSTN)methodr0) transportrrr _transport_method=sr9cCs@|dkr iSdt|i}z|j|d<Wntk r:YnX|S)Nr7url)r9r:r0)r8Z request_inforrr _request_info_from_transportIsr;cs*tjjttfdd}|tj_dS)Nc st}|t||z||f||WStk r|}z2t|tjdddd\}}t|||W5d}~XYnXdS)NrF)typeZhandled)Zclient_optionsZ mechanism) sentry_sdkZget_isolation_scopeZadd_event_processor_make_gql_event_processorrrZ get_clientoptionsZ capture_event)selfr3argskwargsscopeeeventhintZ real_executerr sentry_patched_execute^s  z._patch_execute..sentry_patched_execute)rZClientexecuterr)rHrrGr r%Zsr%csfdd}|S)Nc sz|ddj}Wnttfk r.d}YnX|di}|dditjtrt|d<|di}|di}|d |i|d |S) Nexc_inforrequestZ api_targetgraphqlr4contextsresponseerrors)r4r<) rOr0KeyError setdefaultupdater;r8rr5)rErFrOrKrMrNclientr3rr processorus,     z,_make_gql_event_processor..processorr)rTr3rUrrSr r>ssr>)(r=Zsentry_sdk.utilsrrrZsentry_sdk.integrationsrrZsentry_sdk.scoperrrLrr r r Z gql.transportr r Zgql.transport.exceptionsr ImportErrortypingrrrrrZsentry_sdk._typesrrrZ EventDataTyper#rr5r9r;r%r>rrrr s,