Error loading schema when using a private constructor #4247
-
|
The class Book contains two constructors. The first constructor is private with no parameters. The second constructor is public with parameters. The schema cannot be reloaded. Continuously reported: "Retry schema fetching". Startup.cs BookType.cs Mutation.cs MutationType.cs If the constructor Book(){} becomes public, the schema will be loaded successfully. But, I can only use the private constructor no parameterless. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
The issue in your example is that you are using BookType as the query type. The GraphQL root types must provide a public constructor or you can provide a custom DI registration in which case we will use your DI registration instead of looking for a constructor. Why are you using book as a query type, this makes not really sense. |
Beta Was this translation helpful? Give feedback.

The issue in your example is that you are using BookType as the query type.
The GraphQL root types must provide a public constructor or you can provide a custom DI registration in which case we will use your DI registration instead of looking for a constructor.
Why are you using book as a query type, this makes not really sense.