DEV Community

loading...

Using proxy with GraphQL.Client in C#

eliasj profile image Elias Johnstone ・1 min read

Here is a short snippet how to set up proxy with GraphQL.Client in C#. In this example I use a local proxy for debugging.

var proxy = new WebProxy
{
    Address = new Uri($"http://127.0.0.1:8888"),
};

var httpClientHandler = new HttpClientHandler
{
    Proxy = proxy,
};

var options = new GraphQLHttpClientOptions
{
    EndPoint = new Uri("https://test.com/graphql"),
    HttpMessageHandler = httpClientHandler
};

var graphQLClient = new GraphQLHttpClient(
    options,
    new NewtonsoftJsonSerializer()
);
Enter fullscreen mode Exit fullscreen mode

Discussion (0)

pic
Editor guide