I'm trying to implement Hotchocolate on multi-layered APIs like the following
A -> B -> C, D, E, ...
Here is my request :
{
objectC(id: 111){
fieldA
fieldB
}
}
If I execute this from B, it works perfectly, I can re-execute it without any error.
When I execute this same request from A, it works on the first call but the next ones (same request body) will return "Specified method is not supported" each time while I don't restart B service. If I add a new field in the request, it does the same, works on first execution and errors on the next ones.
C, D, E, .. defines EntityFramework implementation of Hotchocolate GraphQL withtout any extension. It implements Dataloaders :
private void ConfigureServicesGraphQL(IServiceCollection services)
{
services
.AddGraphQLServer()
.AddQueryType(d => d.Name("Query"))
.AddType<ObjectCQuery>()
.AddType<ObjectCType>()
.AddDataLoader<ObjectCByIdDataLoader>()
.EnableRelaySupport()
.AddFiltering()
.AddSorting();
}
B implements stitching schema of C, D, E and the others and extend types to add business value :
private void ConfigureServicesGraphQL(IServiceCollection services)
{
// Clients
services.AddHttpClient("ObjectC", (sp, client) => { client.BaseAddress = new Uri(Configuration.GetValue<string>("urls:ObjectC") + "/v1/graphql"); });
services.AddHttpClient("ObjectD", (sp, client) => { client.BaseAddress = new Uri(Configuration.GetValue<string>("urls:ObjectD") + "/v1/graphql"); });
services.AddHttpClient("ObjectE", (sp, client) => { client.BaseAddress = new Uri(Configuration.GetValue<string>("urls:ObjectE") + "/v1/graphql"); });
services
.AddGraphQLServer()
// Remote Schemas
.AddRemoteSchema("ObjectC", false)
.AddRemoteSchema("ObjectD", false)
.AddRemoteSchema("ObjectE", false)
// Extensions
.AddTypeExtensionsFromFile("ObjectCExtensions.graphql")
.AddTypeExtensionsFromFile("ObjectDExtensions.graphql")
.AddTypeExtensionsFromFile("ObjectEExtensions.graphql")
// Options
.AddErrorFilter<GraphQLErrorFilter>();
}
A implements stitching schema of B and extend types to add new business value :
private void ConfigureServicesGraphQL(IServiceCollection services)
{
// Clients
services.AddHttpClient("ObjectB", (sp, client) => { client.BaseAddress = new Uri(Configuration.GetValue<string>("urls:ObjectB") + "/v1/graphql"); });
services.AddGraphQLServer()
// Merge Directive Rule to manage multi layered stitching
.AddDirectiveMergeRule(next => (c, d) =>
{
List<IDirectiveTypeInfo> newDirectives = new List<IDirectiveTypeInfo>();
List<IDirectiveTypeInfo> returnedValue = (List<IDirectiveTypeInfo>)d;
List<string> dirToRemove = new List<string>()
{
"delegate",
"cost",
"computed",
"source"
};
foreach (var dti in returnedValue)
{
ISchemaInfo si = dti.Schema;
foreach (var dir in dirToRemove)
((Dictionary<string, DirectiveDefinitionNode>)si.Directives).Remove(dir);
if (!dirToRemove.Contains(dti.Definition.Name.Value))
newDirectives.Add(new DirectiveTypeInfo(dti.Definition, si));
}
next(c, newDirectives);
})
.AddRemoteSchema("ObjectB")
.AddTypeExtensionsFromFile("Extensions.graphql")
.AddErrorFilter<GraphQLErrorFilter>()
}
I don't understand why the same request does not work twice.. I presume some cache on "B", i tried a lot of configurations (requests options, tracing preferences, strict validation ...) but same result.
Help please ! :)
question from:
https://stackoverflow.com/questions/65881989/hotchocolate-specified-method-is-not-supported