ngraphql icon indicating copy to clipboard operation
ngraphql copied to clipboard

[NGraphQL.Client] Include Browser Request Credential for WebAssembly app

Open jasonlaw opened this issue 1 month ago • 1 comments

Hi @rivantsov ,

I’m using NGraphQL.Client in a Blazor WebAssembly app and noticed that cookies are not being set or sent with GraphQL requests. After some investigation, it seems this is due to the browser’s default RequestCredentials policy.

In Blazor WebAssembly, we need to explicitly set:

request.SetBrowserRequestCredentials(BrowserRequestCredentials.Include);

to ensure cookies (e.g., authentication or session tokens) are included in requests.

Would it be possible to add a configurable parameter for that ?

Thanks in advance!

jasonlaw avatar Nov 12 '25 04:11 jasonlaw

Good point. But adding a flag to do it automatically is not possible, since using this method inside GraphQL client would require referencing WebAssembly dll. So the proper way would be is to intercept the Http request message (with event handler), right before it is sent. There is an interceptor event in GraphQL client, but it is at higher level, before creating final HttpRequestMessage. I will add this interceptor, and also look at other issue, try to do it soon. thanks

rivantsov avatar Nov 12 '25 18:11 rivantsov