Skip to content

The agent engineering platform.

community[patch]: Allow override of 'fetch_schema_from_transport' in the GraphQL tool (#17649)

Zachary Toliver29ee0496b6aa
diff --git a/libs/community/langchain_community/utilities/graphql.py b/libs/community/langchain_community/utilities/graphql.py
index a576419e5b..0478aef78e 100644
--- a/libs/community/langchain_community/utilities/graphql.py
+++ b/libs/community/langchain_community/utilities/graphql.py
@@ -12,6 +12,7 @@ class GraphQLAPIWrapper(BaseModel):
"""
custom_headers: Optional[Dict[str, str]] = None
+ fetch_schema_from_transport: Optional[bool] = None
graphql_endpoint: str
gql_client: Any #: :meta private:
gql_function: Callable[[str], Any] #: :meta private:
diff --git a/libs/community/tests/unit_tests/utilities/test_graphql.py b/libs/community/tests/unit_tests/utilities/test_graphql.py
index 2ef9be654b..82c75e21c0 100644
--- a/libs/community/tests/unit_tests/utilities/test_graphql.py
+++ b/libs/community/tests/unit_tests/utilities/test_graphql.py
@@ -85,6 +85,7 @@ def test_run() -> None:
graphql_wrapper = GraphQLAPIWrapper(
graphql_endpoint=TEST_ENDPOINT,
custom_headers={"Authorization": "Bearer testtoken"},
+ fetch_schema_from_transport=True,
)
result = graphql_wrapper.run(query)
diff --git a/libs/langchain/langchain/agents/load_tools.py b/libs/langchain/langchain/agents/load_tools.py
index 24adaf867d..ab49c39a4a 100644
--- a/libs/langchain/langchain/agents/load_tools.py
+++ b/libs/langchain/langchain/agents/load_tools.py
@@ -453,7 +453,10 @@ _EXTRA_OPTIONAL_TOOLS: Dict[str, Tuple[Callable[[KwArg(Any)], BaseTool], List[st
),
"stackexchange": (_get_stackexchange, []),
"sceneXplain": (_get_scenexplain, []),
- "graphql": (_get_graphql_tool, ["graphql_endpoint", "custom_headers"]),
+ "graphql": (
+ _get_graphql_tool,
+ ["graphql_endpoint", "custom_headers", "fetch_schema_from_transport"],
+ ),
"openweathermap-api": (_get_openweathermap, ["openweathermap_api_key"]),
"dataforseo-api-search": (
_get_dataforseo_api_search,