graphql-platform: UseFiltering() fails with Azure Function host
Hi All,
Describe the bug Azure Function Filteirng Exception is raised for Implicit Filtering.
System.InvalidOperationException: ‘No coercion operator is defined between types ‘System.Object’ and ‘System.Void’.’
If I add a Explicit Filtering Type it seems to be ok. However I do not want to have to define the explicit filters everywhere.
To Reproduce Using Repository located https://github.com/OneCyrus/GraphQL-AzureFunctions-HotChocolate
Steps to reproduce the behavior:
-
Download the above sample repository.
-
Install NuGet package for HotChocolate.Types.Filters 10.3.0
-
Update QueryType.cs to add UseFiltering() to the first field for GetHero.
protected override void Configure(IObjectTypeDescriptor<Query> descriptor)
{
descriptor.Field(t => t.GetHero(default))
.Type<CharacterType>()
.Argument("episode", a => a.DefaultValue(Episode.NewHope))
.UseFiltering();
descriptor.Field(t => t.GetCharacter(default, default))
.Type<NonNullType<ListType<NonNullType<CharacterType>>>>()
.Argument("characterIds",
a => a.Type<NonNullType<ListType<NonNullType<IdType>>>>());
descriptor.Field(t => t.GetHuman(default))
.Argument("id", a => a.Type<NonNullType<IdType>>());
descriptor.Field(t => t.GetDroid(default))
.Argument("id", a => a.Type<NonNullType<IdType>>());
}
- Run a standard unrelated query
{
droid (id:2000) {
id,
name,
friends {
name
}
}
}
Error message
Executed 'graphql' (Failed, Id=1de29352-d7cd-4282-9858-67626a82d8c1)
[07/01/2020 13:47:46] HotChocolate.Types: Unable to create instance of type `HotChocolate.Types.Filters.FilterInputType`1[[StarWars.Models.ICharacter, GraphQL-AzureFunctions-HotChocolate, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]`.
[07/01/2020 13:47:46] An unhandled host error has occurred.
[07/01/2020 13:47:46] HotChocolate.Types: Unable to create instance of type `HotChocolate.Types.Filters.FilterInputType`1[[StarWars.Models.ICharacter, GraphQL-AzureFunctions-HotChocolate, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]`.
Which seems to comes from an internal exception (as seen in Preview of VS 2019) System.InvalidOperationException: ‘No coercion operator is defined between types ‘System.Object’ and ‘System.Void’.’
Desktop (please complete the following information): OS: Windows 10 Visual Studio Community 2019 .Net Core 3.0 Azure Runtime v3
Any assistance would be greatly appreciated.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 20 (14 by maintainers)
I’m looking into this now. the issue is with GetService in https://github.com/ChilliCream/hotchocolate/blob/fafbac232b86a3a0fb48090a2cffff735e2253e8/src/Core/Utilities/ServiceFactory.cs#L143
GetService throws an exception in Azure Functions when it doesn’t find something in the DI container. In Asp.Net Core it returns null. I’m in talk with Microsoft if this behaviour is really intended that way and if they don’t want to align it.
I think I will rewrite the dependency injection integration if hc so that we never need to fetch services that do not exist… For ms to fix that will take to long.
This is actually a bug with the azure functions di since the IServiceProvider interfaces explicitly states that null shall be returned if a service does not exist.
@OneCyrus what is the status on this?
We could create a workaround if ms is not fixing this. But lets wait for Daniel to give a status.
@OneCyrus https://docs.microsoft.com/en-us/dotnet/api/system.iserviceprovider.getservice?view=netcore-3.1