DEV Community

Elias Johnstone
Elias Johnstone

Posted on

Using proxy with GraphQL.Client in C#

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

Top comments (0)