You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// startup/registration DI code - services.AddHttpClient("GraphQLClient").ConfigureHttpClient(client =>{client.BaseAddress=newUri("https://api.example.com/graphql");});services.AddScoped<GraphQLHttpClient>(sp =>{varhttpClientFactory=sp.GetRequiredService<IHttpClientFactory>();varhttpClient=httpClientFactory.CreateClient("GraphQLClient");returnnewGraphQLHttpClient(newGraphQLHttpClientOptions{EndPoint=newUri("https://api.example.com/graphql")},newSystemTextJsonSerializer(),httpClient);});publicclassClient{privatereadonlyGraphQLHttpClient_graphqlClient;publicClient(GraphQLHttpClientgraphqlClient){this._graphqlClient=graphqlClient;}publicasyncTaskSomeMethod(){varrequest1=newGraphQLRequest{Query="{ students { id name } }"};varrequest2=newGraphQLRequest{Query="{ courses { id title } }"};vart=CallApi(request1);varm=CallApi(request2);// This throws Cannot access a disposed object Object name: System.Net.Http.StringContent exceptionawaitTask.WhenAll(t,m);}privateasyncTaskCallApi(GraphQLRequestrequest){varresponse=await_graphqlClient.SendQueryAsync<dynamic>(request);// exception thrown here Console.WriteLine(response.Data);}}
The text was updated successfully, but these errors were encountered:
Code -
The text was updated successfully, but these errors were encountered: