Search code examples
graphqljwtmicroservicesasp.net-core-6.0hotchocolate

How to implement GraphQL schema stitching with authentication for microservices in .NET Core 6


How we can pass auth token to micro services when we use GraphQL schema stitching with authorization for micro services in .NET Core 6 Hotchocolate?


Solution

  • You can use the Microsoft.AspNetCore.HeaderPropagation NuGet package to forward the Authorization header to your services.

    services.AddHeaderPropagation(options =>
    {
        options.Headers.Add("Authorization");
    });
    
    app.UseHeaderPropagation();