Share via

Dependency Injection: one interface multiple times

Vop Royal 1 Reputation point
2021-09-01T13:52:01.177+00:00

hello all,

using .net core .31 i have a situation that in Dependency injection i have to use one Interface with different url's. below is my existing code.

public static IServiceCollection ResolveDependencies(this IServiceCollection services, IConfiguration configuration)
{
var graphQlHttpClient = new GraphQLHttpClient(
configuration["MyGraphqlLink"],
new NewtonsoftJsonSerializer());

            services.AddSingleton<IGraphQLClient>(s => graphQlHttpClient);
    }

above is existing code and its working fine. but, i have a scenario that i have to use 2 or 3 graphql link also in the same section so, may i know how do i use GraphQLHttpClient
with 2 or 3 different URL's?

experts kindly support.

Developer technologies | ASP.NET Core | Other

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.