OneCyrus / GraphQL-AzureFunctions-HotChocolate

running a HotChocolate GraphQL server in Azure Functions
MIT License
19 stars 5 forks source link

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

Open danvanderboom opened 4 years ago

danvanderboom commented 4 years ago

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.

OneCyrus commented 4 years ago

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.