GraphQL-AzureFunctions-HotChocolate icon indicating copy to clipboard operation
GraphQL-AzureFunctions-HotChocolate copied to clipboard

App doesn't work with nullable reference types in C# 8.0, which affects HotChocolate schema type inference

Open danvanderboom opened this issue 4 years ago • 1 comments

Thanks for building this sample app. It was really helpful in getting up and running with HotChocolate in our Azure Functions app.

The one thing I noticed was in pulling everything into a project with nullable reference types enabled, I got these errors:

HotChocolate.SchemaException: 'Multiple schema errors occured: The return type of the interface field name does not match the field declared by object type Human. - Type: Human The return type of the interface field name does not match the field declared by object type Droid. - Type: Droid

There are a few places here and there where I was able to update the schema types to define NonNullTypes (for string and float properties), and to make relationship properties explicitly nullable in the model classes, to get it to work.

danvanderboom avatar Jun 24 '20 17:06 danvanderboom

the example uses the code first approach and not the pure code first yet. so you need to keep the specific types up to date and can't just use nullable reference types. if you want to work with the C# 8.0 nullable type feature, you should use pure code first.

OneCyrus avatar Jun 25 '20 14:06 OneCyrus