graphql-dotnet / graphql-dotnet/graphql-client

Adding headers at the request level

Open
#330 2 comments 0 reactions 0 assignees View on GitHub
question
Dominant language
C#
Stars
648
Forks
136
PR merge metrics
No merged PRs in 30d

Description

I understand that you can add headers at the client level (that get sent for every request) but how can I add a header at the
request level.

e.g. This code shows how DefaultRequestHeaders can be set, but what if I wanted to add a request level header for say a Correlation Id?
```
var graphClient = new GraphQLClient("https://api.github.com/graphql");
graphClient.DefaultRequestHeaders.Add("Authorization", $"bearer {gitHubAccessToken}");
//var test = await graphClient.GetIntrospectionQueryAsync();
var request = new GraphQLRequest
{
Query = @"query { viewer { login } }"
};
var test = await graphClient.PostAsync(request);
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.