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

AddQueryType with changed name does not effect types extending ObjectTypeExtension

Open anuith opened this issue 2 years ago • 1 comments

Is there an existing issue for this?

  • [x] I have searched the existing issues

Describe the bug

When added server with builder.AddQueryType<QueryType>(d => d.Name("Query")

That name does not have effect on types that extending ObjectTypeExtension<QueryType> and it makes the queries on this type not available on schema.

Steps to reproduce

  1. Create a placeholder class QueryType
public class QueryType { }
  1. In Startup.ConfigureServices() : add AddQueryType<QueryType>(d => d.Name("Query"))
services
  .AddGraphQLServer()
  .AddQueryType<QueryType>(d => d.Name("Query"));
  1. Create a class that extends ObjectTypeExtension<QueryType>
public class HelloQuery : ObjectTypeExtension<QueryType>
{
  protected override void Configure(IObjectTypeDescriptor<QueryType> descriptor)
  {
      // descriptor here has definition name "QueryType" not "Query"
      // and query "hello" will not show on the schema
      descriptor.Field("hello").Resolve("Hello World");
  }
}

Relevant log output

No response

Additional Context?

No response

Product

Hot Chocolate

Version

12.11.11

anuith avatar Sep 12 '22 03:09 anuith

A way to avoid is to not change the name of QueryType descriptor or add descriptor.Name("Query") in every classes that extends ObjectTypeExtension<QueryType>

anuith avatar Sep 12 '22 03:09 anuith