@@ -24,7 +24,7 @@ class GraphClientFactory(KiotaClientFactory):
2424 @staticmethod
2525 def create_with_default_middleware (
2626 api_version : APIVersion = APIVersion .v1 ,
27- client : httpx .AsyncClient = KiotaClientFactory . get_default_client () ,
27+ client : Optional [ httpx .AsyncClient ] = None ,
2828 host : NationalClouds = NationalClouds .Global ,
2929 options : Optional [Dict [str , RequestOption ]] = None
3030 ) -> httpx .AsyncClient :
@@ -44,6 +44,8 @@ def create_with_default_middleware(
4444 Returns:
4545 httpx.AsyncClient: An instance of the AsyncClient object
4646 """
47+ if client is None :
48+ client = KiotaClientFactory .get_default_client ()
4749 client .base_url = GraphClientFactory ._get_base_url (host , api_version ) # type: ignore
4850 middleware = KiotaClientFactory .get_default_middleware (options )
4951 telemetry_handler = GraphClientFactory ._get_telemetry_handler (options )
@@ -54,7 +56,7 @@ def create_with_default_middleware(
5456 def create_with_custom_middleware (
5557 middleware : Optional [List [BaseMiddleware ]],
5658 api_version : APIVersion = APIVersion .v1 ,
57- client : httpx .AsyncClient = KiotaClientFactory . get_default_client () ,
59+ client : Optional [ httpx .AsyncClient ] = None ,
5860 host : NationalClouds = NationalClouds .Global ,
5961 ) -> httpx .AsyncClient :
6062 """Applies a custom middleware chain to the HTTP Client
@@ -70,6 +72,8 @@ def create_with_custom_middleware(
7072 host (NationalClouds): The national clound endpoint to be used.
7173 Defaults to NationalClouds.Global.
7274 """
75+ if client is None :
76+ client = KiotaClientFactory .get_default_client ()
7377 client .base_url = GraphClientFactory ._get_base_url (host , api_version ) # type: ignore
7478 return GraphClientFactory ._load_middleware_to_client (client , middleware )
7579
0 commit comments