
    dh                     N    S SK r S SKJrJrJrJr  S SKJrJrJ	r	   " S S\5      r
g)    N)AnyCallableDictOptional)	BaseModel
ConfigDictmodel_validatorc                       \ rS rSr% SrSr\\\\4      \	S'   Sr
\\   \	S'   \\	S'   Sr\\	S'   \\/\4   \	S'   \" S	S
9r\" SS9\S\S\4S j5       5       rS\S\4S jrS\S\\\4   4S jrSrg)GraphQLAPIWrapper   zWrapper around GraphQL API.

To use, you should have the ``gql`` python package installed.
This wrapper will use the GraphQL API to conduct queries.
Ncustom_headersfetch_schema_from_transportgraphql_endpoint
gql_clientgql_functionforbid)extrabefore)modevaluesreturnc                      SSK JnJ n  SSKJn  UR                  S5      nU" US   US9nUR                  S	S
5      nU" XxS9n	XS'   X1S'   U$ ! [         a  n[	        SU 35      eSnAff = f)z;Validate that the python package exists in the environment.r   )Clientgql)RequestsHTTPTransportz_Could not import gql python package. Try installing it with `pip install gql`. Received error: Nr   r   )urlheadersr   T)	transportr   r   r   )r   r   gql.transport.requestsr   ImportErrorget)
clsr   r   r   r   er   r   r   clients
             ]/var/www/html/shao/venv/lib/python3.13/site-packages/langchain_community/utilities/graphql.pyvalidate_environment&GraphQLAPIWrapper.validate_environment   s    	'D **-.))*
	 '-jj1NPT&U#
  &|!$~!  	MMNCQ 	s   A 
A*A%%A*queryc                 N    U R                  U5      n[        R                  " USS9$ )z(Run a GraphQL query and get the results.   )indent)_execute_queryjsondumps)selfr(   results      r%   runGraphQLAPIWrapper.run1   s#    $$U+zz&++    c                 ^    U R                  U5      nU R                  R                  U5      nU$ )z/Execute a GraphQL query and return the results.)r   r   execute)r/   r(   document_noder0   s       r%   r,    GraphQLAPIWrapper._execute_query6   s+    ))%0((7r3    )__name__
__module____qualname____firstlineno____doc__r   r   r   str__annotations__r   boolr   r   r   r   model_configr	   classmethodr&   r1   r,   __static_attributes__r8   r3   r%   r   r      s     04NHT#s(^,326$6JC5#:&&L (#$ 3   $., , ,
C DcN r3   r   )r-   typingr   r   r   r   pydanticr   r   r	   r   r8   r3   r%   <module>rF      s      0 0 ; ;3	 3r3   