ChilliCream / ChilliCream/graphql-platform
ScalarSerializer is not found by ISerializerResolver
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 5.8k
- Forks
- 810
- Avg merge
- 15h 39m
- Merged PRs (30d)
- 98
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
Custom ScalarSerializer not found when when initializing client.
Steps to reproduce
- Given a schema like this:
type Outage {
id: String!
fasoId: [String!]!
name: String
category: String
product: String
startTime: AWSDateTime
endTime: AWSDateTime
expectedEndTime: AWSDateTime
}
scalar AWSDateTime
- Add the following to schema.extensions.graphql:
extend scalar AWSDateTime
@serializationType(name: "global::System.String")
@runtimeType(name: "global::System.DateTime")
- Add a ScalarSerializer:
public class StrawberryShakeDateTimeSerializer : ScalarSerializer<string, DateTime>
{
public StrawberryShakeDateTimeSerializer() : base("AWSDateTime")
{
}
public override DateTime Parse(string serializedValue)
{
throw new NotImplementedException();
}
protected override string Format(DateTime runtimeValue)
{
throw new NotImplementedException();
}
}
- Check one of the relevant Initalize() methods using AWSDateTime. It should look something like:
public void Initialize(global::StrawberryShake.Serialization.ISerializerResolver serializerResolver)
{
_stringFormatter = serializerResolver.GetInputValueFormatter("String");
_aWSDateTimeFormatter = serializerResolver.GetInputValueFormatter("AWSDateTime");
}
- Run the project, and try to initialize the client. You will now get the following exception:
My.Test.Agent.Microcore.TestIntegration.Controller.TestIntegrationController: Error: TestMethod Exception: System.ArgumentException: There is no formatter registered the specified type.
at StrawberryShake.Serialization.SerializerResolver.GetInputValueFormatter(String typeName)
at My.Test.Agent.Microcore.TestIntegration.Client.GetTicketInputInputValueFormatter.Initialize(ISerializerResolver serializerResolver) in C:\Users\username\projects\test-integration-ms\TestIntegrationSvc\StrawberryShake.CodeGeneration.CSharp.Analyzers\StrawberryShake.CodeGeneration.CSharp.Analyzers.CSharpClientGenerator\ChipperClient.StrawberryShake.cs:line 14474
at StrawberryShake.Serialization.SerializerResolver..ctor(IEnumerable`1 serializers)
at Microsoft.Extensions.DependencyInjection.ChipperClientServiceCollectionExtensions.<>c__DisplayClass1_0.<ConfigureClientDefault>b__2(IServiceProvider sp) in C:\Users\username\projects\test-integration-ms\TestIntegrationSvc\StrawberryShake.CodeGeneration.CSharp.Analyzers\StrawberryShake.CodeGeneration.CSharp.Analyzers.CSharpClientGenerator\ChipperClient.StrawberryShake.cs:line 100
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.CreateServiceAccessor(Type serviceType)
at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ChipperClientServiceCollectionExtensions.<>c.<ConfigureClientDefault>b__1_10(IServiceProvider sp) in C:\Users\username\projects\test-integration-ms\TestIntegrationSvc\StrawberryShake.CodeGeneration.CSharp.Analyzers\StrawberryShake.CodeGeneration.CSharp.Analyzers.CSharpClientGenerator\ChipperClient.StrawberryShake.cs:line 114
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.CreateServiceAccessor(Type serviceType)
at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ChipperClientServiceCollectionExtensions.<>c.<ConfigureClientDefault>b__1_19(IServiceProvider sp) in C:\Users\username\projects\test-integration-ms\TestIntegrationSvc\StrawberryShake.CodeGeneration.CSharp.Analyzers\StrawberryShake.CodeGeneration.CSharp.Analyzers.CSharpClientGenerator\ChipperClient.StrawberryShake.cs:line 131
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.CreateServiceAccessor(Type serviceType)
at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType)
at Microsoft.Extensions.DependencyInjection.ChipperClientServiceCollectionExtensions.ClientServiceProvider.GetService(Type serviceType) in C:\Users\username\projects\test-integration-ms\TestIntegrationSvc\StrawberryShake.CodeGeneration.CSharp.Analyzers\StrawberryShake.CodeGeneration.CSharp.Analyzers.CSharpClientGenerator\ChipperClient.StrawberryShake.cs:line 145
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ChipperClientServiceCollectionExtensions.<>c.<AddChipperClient>b__0_7(IServiceProvider sp) in C:\Users\username\projects\test-integration-ms\TestIntegrationSvc\StrawberryShake.CodeGeneration.CSharp.Analyzers\StrawberryShake.CodeGeneration.CSharp.Analyzers.CSharpClientGenerator\ChipperClient.StrawberryShake.cs:line 23
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.CreateServiceAccessor(Type serviceType)
at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
at My.Test.Agent.Microcore.TestIntegration.ClientFactory.RefreshClient(JwtSecurityToken jwtSecurityToken) in C:\Users\username\projects\test-integration-ms\TestIntegrationSvc\TestIntegration\ClientFactory.cs:line 122
at My.Test.Agent.Microcore.TestIntegration.ClientFactory.Client() in C:\Users\username\projects\test-integration-ms\TestIntegrationSvc\TestIntegration\ClientFactory.cs:line 43
at My.Test.Agent.Microcore.TestIntegration.Facade.TestIntegrationFacade.TestMethod_GraphQL(String id, List`1 status) in C:\Users\username\projects\test-integration-ms\TestIntegrationSvc\TestIntegration\Facade\TestIntegrationFacade.cs:line 135
at My.Test.Agent.Microcore.TestIntegration.Controller.TestIntegrationController.TestMethod_GraphQL(String incidentId, List`1 status) in C:\Users\username\projects\test-integration-ms\TestIntegrationSvc\TestIntegration\Controller\TestIntegrationController.cs:line 131
Debugging confirms that the ScalarSerializer is not part of the list of Serializers.
Relevant log output
No response
Additional Context?
No response
Product
Strawberry Shake
Version
12.11.1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with ScalarSerializer and ISerializerResolver, then reproduce the AWSDateTime setup from schema.extensions.graphql. Inspect the generated Initialize method and the serializer list involved during SerializerResolver construction. Done means a custom ScalarSerializer is registered and GetInputValueFormatter("AWSDateTime") succeeds when the client initializes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, graphql
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100