You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have to use records in my project. So I did somethink like:
[GraphQLName("IChannel")]publicinterfaceIChannelDto{[ID]GuidId{get;init;}stringDescription{get;init;}
#region workaround
// TODO: delete after Hot Chocolate Team fixes one of two issue:// - ExtendObjectType should extend interface and all derived classes// - interface default methods implementations must be used in derived classesTask<ChannelStatus>GetStatusAsync(){thrownew NotImplementedException();}
#endregion
}[ExtendObjectType(typeof(IChannelDto))]publicclassChannelResolvers{publicasyncTask<ChannelStatus>GetStatusAsync(){// Do some stuff}}[GraphQLName("ChannelTypeA")]publicrecordChannelTypeADto([property:ID]GuidId,stringDescription,stringIP,):IChannelDto;[UnionType("IAnotherChannel")]publicinterfaceIAnotherChannelDto:IChannelDto{};[GraphQLName("ChannelTypeB")]publicrecordChannelTypeBDto([property:ID]GuidId,stringDescription,stringPort,):IAnotherChannelDto;[GraphQLName("ChannelTypeC")]publicrecordChannelTypeCDto([property:ID]GuidId,stringDescription,stringAdapter,):IAnotherChannelDto;
Here is a problem:
The ExtendObjectType annotation does not extend interfaces by design but I need it, so I made a workaround. That stub function is never called and I only need it to create the schema.
I can't just remove the class with the ExtendObjectType annotation and put the default implementation inside the interface. Hot chocolate want me to add a Status field inside all derived records.
I must use both the ExtendObjectType annotation and that stub default implementation in the interface. If I could replace records with classes, I would do something like:
[InterfaceType("IChannel")]publicabstractclassChannelDto{[ID]publicGuidId{get;init;}publicstringDescription{get;init;}publicasyncTask<ChannelStatus>GetStatusAsync(){// Do some stuff}}[GraphQLName("ChannelTypeA")]publicclassChannelTypeADto:ChannelDto{publicstringIP{get;init;}}[UnionType("IAnotherChannel")]publicabstractclassAnotherChannelDto:ChannelDto{};[GraphQLName("ChannelTypeB")]publicclassChannelTypeBDto:AnotherChannelDto{publicstringPort{get;init;}}[GraphQLName("ChannelTypeC")]publicclassChannelTypeCDto:AnotherChannelDto{publicstringAdapter{get;init;}}
This works nice!
The solution you'd like
One of:
Let the ExtendObjectType annotation extend interfaces.
Add support for the default method implementation in the schema inference algorithm.
The text was updated successfully, but these errors were encountered:
Product
Hot Chocolate
Is your feature request related to a problem?
Lets imagine we want the Hot Chocolate to produce a schema like:
I have to use records in my project. So I did somethink like:
Here is a problem:
Status
field inside all derived records.I must use both the ExtendObjectType annotation and that stub default implementation in the interface. If I could replace records with classes, I would do something like:
This works nice!
The solution you'd like
One of:
The text was updated successfully, but these errors were encountered: