简体   繁体   中英

Dynamically choosing the schema using HotChocolate - GraphQL

I'm struggling trying to dynamically choose the schema which I want to use based on information sent on the request.

Example:

If I send a request to an specific URL -.../graphql/schema/{id} - I can get the id from the slug. With that ID, I want to get the schema (stored on a database where it can be updated as many time the user wants) and execute the query against it.

I can already do this using graphql-dotnet, but I want to use HotChocolate in order to take advantage of all the features that it provides. I've wasted many hours so far and I'm not being successful.

I've looked into the implementation of the IRequestExecutorResolver and I realized that the RequestExecutor is chosen according to the schemaName. Is there any way to, at runtime, add and edit the current list of executors? Or is there any easier way to resolve my problem?

At the moment we do not allow dynamic routes. Meaning you at the moment can have multiple schemas but they are fixed to a specific route.

https://github.com/ChilliCream/hotchocolate/blob/07e1f33cef90ca41624fc94f168ade82d4cc6e73/src/HotChocolate/AspNetCore/src/AspNetCore/Extensions/EndpointRouteBuilderExtensions.cs#L132

This could be changed. File an issue on our repo and we will put it on the backlog.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM