a
    bg                     @   sH   d dl Z d dlmZmZmZmZ d dlmZmZm	Z	 G dd deZ
dS )    N)AnyCallableDictOptional)	BaseModel
ConfigDictmodel_validatorc                   @   s   e Zd ZU dZdZeeeef  ed< dZ	ee
 ed< eed< dZeed< eegef ed< edd	Zed
deeedddZeedddZeeeef dddZdS )GraphQLAPIWrapperzWrapper 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_functionZforbid)extrabefore)mode)valuesreturnc           
   
   C   s   z ddl m}m } ddlm} W n2 tyR } ztd| W Y d}~n
d}~0 0 |d}||d |d}|d	d
}|||d}	|	|d< ||d< |S )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   Zgql.transport.requestsr   ImportErrorget)
clsr   r   r   r   er   r   r   client r   s/var/www/html/cobodadashboardai.evdpl.com/venv/lib/python3.9/site-packages/langchain_community/utilities/graphql.pyvalidate_environment   s*    
z&GraphQLAPIWrapper.validate_environment)queryr   c                 C   s   |  |}tj|ddS )z(Run a GraphQL query and get the results.   )indent)_execute_queryjsondumps)selfr"   resultr   r   r    run1   s    
zGraphQLAPIWrapper.runc                 C   s   |  |}| j|}|S )z/Execute a GraphQL query and return the results.)r   r   execute)r(   r"   Zdocument_noder)   r   r   r    r%   6   s    
z GraphQLAPIWrapper._execute_query)__name__
__module____qualname____doc__r
   r   r   str__annotations__r   boolr   r   r   r   Zmodel_configr   classmethodr!   r*   r%   r   r   r   r    r	      s   
r	   )r&   typingr   r   r   r   Zpydanticr   r   r   r	   r   r   r   r    <module>   s   