graphql-platform icon indicating copy to clipboard operation
graphql-platform copied to clipboard

Cannot resolve 'HotChocolate.Execution.Processing.OperationContext'

Open tobias-tengler opened this issue 1 year ago • 2 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Describe the bug

Executing any request against a GraphQL server running the latest preview yields the following error:

System.InvalidOperationException: Cannot resolve 'HotChocolate.Execution.Processing.OperationContext' from root provider because it requires scoped service 'HotChocolate.Execution.DependencyInjection.IFactory`1[HotChocolate.Execution.Processing.DeferredWorkStateOwner]'.

Steps to reproduce

I just switched over a working project of the latest v12 to the latest preview version and noticed this error. Couldn't narrow it down to any wrongdoing in our application code.

Relevant log output

System.InvalidOperationException: Cannot resolve 'HotChocolate.Execution.Processing.OperationContext' from root provider because it requires scoped service 'HotChocolate.Execution.DependencyInjection.IFactory`1[HotChocolate.Execution.Processing.DeferredWorkStateOwner]'.
         at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.ValidateResolution(Type serviceType, IServiceScope scope, IServiceScope rootScope)
         at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
         at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)
         at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
         at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
         at Microsoft.Extensions.ObjectPool.DefaultObjectPool`1.Create()
         at Microsoft.Extensions.ObjectPool.DefaultObjectPool`1.Get()
         at HotChocolate.Execution.Pipeline.OperationExecutionMiddleware.ExecuteOperationAsync(IRequestContext context, IBatchDispatcher batchDispatcher, IOperation operation)
         at HotChocolate.Execution.Pipeline.OperationExecutionMiddleware.InvokeAsync(IRequestContext context, IBatchDispatcher batchDispatcher)
         at HotChocolate.Execution.Pipeline.OperationVariableCoercionMiddleware.InvokeAsync(IRequestContext context)
         at HotChocolate.Execution.Pipeline.OperationResolverMiddleware.InvokeAsync(IRequestContext context)
         at HotChocolate.Execution.Pipeline.OperationComplexityMiddleware.InvokeAsync(IRequestContext context)
         at HotChocolate.Execution.Pipeline.OperationCacheMiddleware.InvokeAsync(IRequestContext context)
         at HotChocolate.Execution.Pipeline.DocumentValidationMiddleware.InvokeAsync(IRequestContext context)
         at HotChocolate.Execution.Pipeline.DocumentParserMiddleware.InvokeAsync(IRequestContext context)
         at HotChocolate.Execution.Pipeline.DocumentCacheMiddleware.InvokeAsync(IRequestContext context)
         at HotChocolate.Execution.Pipeline.TimeoutMiddleware.InvokeAsync(IRequestContext context)
         at HotChocolate.Execution.Pipeline.ExceptionMiddleware.InvokeAsync(IRequestContext context)

Additional Context?

No response

Product

Hot Chocolate

Version

13.0.0-preview.28

tobias-tengler avatar Jul 16 '22 18:07 tobias-tengler

Had this issue myself. Was able to narrow it down to the environment variable ASPNETCORE_ENVIRONMENT in the launch profile in launchSettings.json

image

If this value is set to Development, the issue occurs. If the value is anything else or missing, the project works fine. Not sure how helpful this information is, but posting just in case it can help point in the right direction :)

Was able to reproduce with both launch types below, both have the issue when the environment variable is set, and both work without.

image

nikolai-mb avatar Jul 18 '22 12:07 nikolai-mb

Thanks for your feedback ... we are currently working on fixing this issue.

michaelstaib avatar Jul 18 '22 14:07 michaelstaib

Hope this gets prioritized as It makes all the preview versions after 13.0.0-preview.24 unusable

MoazAlkharfan avatar Aug 15 '22 09:08 MoazAlkharfan

This is fixed in the latest preview.

tobias-tengler avatar Aug 26 '22 08:08 tobias-tengler

Still does not work in 13.0.0-preview.28. I tried to upgrade to latest prerelease (13.0.0-preview.68) and I was not able to compile my .NETCore 3.1 project because of lots of missing classes from HotChocolate.Data. A workaround mentioned above must be made in order to make it work.

kfrajtak avatar Oct 11 '22 12:10 kfrajtak

We no longer support netcore 3.1 for Data since the final release of 13 will be somewhere in December netcore 3.1 will be out of support. Full support of all 13 features is now only available with net 6 and net 7.

michaelstaib avatar Nov 09 '22 18:11 michaelstaib