You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.
Adding HotChocolate.AspNetCore.Authorization to the schema removes the @link directive from the schema.
How to reproduce
create a graphql schema with federation support
using ApolloGraphQL.HotChocolate.Federation;varbuilder= WebApplication.CreateBuilder(args);
builder.Services
.AddGraphQLServer().AddApolloFederationV2().AddQueryType<Query>();varapp= builder.Build();
app.MapGraphQL("/");
app.RunWithGraphQLCommands(args);publicclassQuery{public User GetUser()=>new("1","David");[ReferenceResolver]public User ResolveUser(stringid)=>new(id,"David");}[Key("id")]publicrecordUser(stringId,stringName);
add HotChocolate.AspNetCore.Authorization nuget and add authorization to the schema builder:
using ApolloGraphQL.HotChocolate.Federation;varbuilder= WebApplication.CreateBuilder(args);
builder.Services
.AddGraphQLServer().AddApolloFederationV2().AddAuthorization().AddQueryType<Query>();varapp= builder.Build();
app.MapGraphQL("/");
app.RunWithGraphQLCommands(args);publicclassQuery{public User GetUser()=>new("1","David");[ReferenceResolver]public User ResolveUser(stringid)=>new(id,"David");}[Key("id")]publicrecordUser(stringId,stringName);
print the schema again with dotnet run -- schema export
Hello 👋
I believe this is due to the limitations of the existing HC TypeInterceptor API (that 🤞 will be fixed in their replacement "skimmed" API which is still WIP). Underlying issue is that current HC API is somewhat finicky and depending on the order of processed items you can have side effects that break other things. AFAIK currently it is not possible to apply multiple schema transformations (see: ChilliCream/graphql-platform#6651) so you only get the results of applying the last transformation.
Since the @link definitions are getting removed it looks like HotChocolate.AspNetCore.Authorization also attempts to change the schema object so you will only get the last transformation. You could try changing the order of the extension but I wouldn't be surprised if your HC authorization logic stops working in that case, i.e.
Adding
HotChocolate.AspNetCore.Authorization
to the schema removes the@link
directive from the schema.How to reproduce
dotnet run -- schema export
the schema contains the
@link
directiveHotChocolate.AspNetCore.Authorization
nuget and add authorization to the schema builder:dotnet run -- schema export
Expectation
@link
directiveCurrent Behavior
@link
directive is gone :-(The text was updated successfully, but these errors were encountered: