Hotchocolate: SchemaException: Unable to create instance of type ``

Created on 4 Feb 2020  路  3Comments  路  Source: ChilliCream/hotchocolate

Describe the bug
Types containing methods with a generic type argument yield the following exception:

HotChocolate.SchemaException: Multiple schema errors occured:
Unable to create instance of type ``.
Unable to create instance of type ``.
Unable to create instance of type ``.
Unable to create instance of type ``.
Unable to create instance of type ``.
Unable to create instance of type ``.
Unable to create instance of type ``.
Unable to create instance of type ``.
Unable to create instance of type ``.
Unable to create instance of type ``.

// ...(goes on for a total of 999 errors)

To Reproduce
Steps to reproduce the behavior:

  1. Create a new C# class containing one property and one method that has a generic type. For example:
public class Foo
{
   public string Bar { get; set; }
   public string FooBar<T>() => Bar;
}
  1. Create a class called FooType : ObjectType<Foo>.
  2. Register the FooType with the schemabuilder and notice the exception I mentioned will occur.

Removing the <T> generic type argument works around the issue.
Admittedly, the example here doesn't make much sense, but I have a type in my application that uses the generic type to cast an object to T.

Expected behavior
No error should occur.

Desktop (please complete the following information):

  • OS: Windows
  • Version 10

Additional context

bug

Most helpful comment

Hi,

we will remove generic methods from the auto-detection since they do not make sense.

We will integrate the fix in version 10.4.0

All 3 comments

Hi,

we will remove generic methods from the auto-detection since they do not make sense.

We will integrate the fix in version 10.4.0

Makes sense. Thanks!

After some testing also Methods returning Task without any value seem to cause issues in some scenarios.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

louisjrdev picture louisjrdev  路  3Comments

tunurgitr picture tunurgitr  路  4Comments

RohrerF picture RohrerF  路  3Comments

nigel-sampson picture nigel-sampson  路  5Comments

sascha-andres picture sascha-andres  路  4Comments