I'm getting the following error message when testing queries on a test project:
"The feature Authorization is missing the state with the key HotChocolate.Authorization.UserState"
My TestExecutorHelper has the .AddAuthorization() and .AddAuthorizationPermissions() it still doesn't work.
Does anyone know how i can solve this?
Here's my TestExecutor.ExecuteAsync method
IRequestExecutorBuilder requestExecutor = serviceCollection
.AddAuthorization()
.AddLogging()
.AddGraphQL()
.AddAuthorization()
.AddAuthorizePermissions()
.AddErrorFilter<ErrorFilter>()
.AddQueryType<QueryType>();
var serviceProvider = requestExecutor.Services.BuildServiceProvider();
var request = QueryRequestBuilder.New()
.SetQuery(query)
.SetServices(serviceProvider)
.Create();
var executor = await requestExecutor.BuildRequestExecutorAsync();
return await executor.ExecuteAsync(request);
As I can see, you have this problem because of calling .AddGraphQL()
instead of .AddGraphQLServer()
.
State UserState
is added inside DefaultHttpRequestInterceptor, and DefaultHttpRequestInterceptor
is registered inside AddGraphQLServer, but not in AddGraphQL