Hotchocolate: Dependency exception when not using Subscriptions

Created on 25 Jul 2019  路  5Comments  路  Source: ChilliCream/hotchocolate

With version 9.1.0-preview.35 the application that is not using subscriptions will see a dependency exception that reads like the following

Unable to resolve service for type 'HotChocolate.AspNetCore.Subscriptions.IMessagePipeline' while attempting to activate 'HotChocolate.AspNetCore.Subscriptions.SubscriptionMiddleware'.

This is because ApplicationBuilderExtensions.UseGraphQL always registers SubscriptionMiddleware but it's dependencies aren't registered unless SubscriptionServiceCollectionExtensions.AddGraphQLSubscriptions is also called.

bug

Most helpful comment

It is quite easy to do that ... I can borrow you some code for that. We will I think have this feature also in with V12. But I can give you some snippets for a basic rest middleware and the it is very easy to stitch rest in or OData. Can you join our slack channel? The invitation link is on our readme... the we can discuss things further.

All 5 comments

So, we are now finished with the modularization task, so this one can be solved now.... instead of using UseGraphQL you can now opt tp use specific middlewares:

app
    .UseGraphQLHttpPost()
    .UseGraphQLHttpGet()
    .UseGraphQLHttpGetSchema()

The UseGraphQL is an easy way to get started and has everything in it.

I have documented this here:
https://hotchocolate.io/docs/aspnet

I am trying to setup Schema Stitching using Hot Chocolate schema stitching Version="10.2.0". I received the same error message 'HotChocolate.AspNetCore.Subscriptions.IMessagePipeline' when I set
app.UseGraphQL();

When I changed to
app.UseGraphQLHttpGetSchema(); then my remote schema where not fetch.

Could you help with sample Hot Chocolate schema stitching sample that is using the updated version of Hot Chocolate schema stitching?
Many thanks.

hi @okosodovictor,

this is a bug that we introduced in version 10. The stitching layer is basically missing the message pipeline. You can either add it.

services.AddGraphQLSubscriptions();

or you choose to remove the subscription middleware by specifying which transport middleware you want to use:

app
    .UseGraphQLHttpPost()
    .UseGraphQLHttpGet()
    .UseGraphQLHttpGetSchema();

regarding the UseGraphQLHttpGetSchema() middleware. This is kind of optional and also this particular middleware has an issue with .NET Core 3. We are currently working on a fix for 10.3.0.

Many thanks @michaelstaib

It worked for me when I use services.AddGraphQLSubscriptions();

Now,I have a question that is a little different from above. I wanted to stitch third party REST API that is not GraphQL API. I have checked the swagger documentation (api/swagger/ui), it exposed so many REST endpoints.

Is there any suggestions on how to stitched each of this individual endpoints.

Many thanks,

It is quite easy to do that ... I can borrow you some code for that. We will I think have this feature also in with V12. But I can give you some snippets for a basic rest middleware and the it is very easy to stitch rest in or OData. Can you join our slack channel? The invitation link is on our readme... the we can discuss things further.

Was this page helpful?
0 / 5 - 0 ratings