Welcome to the home of the Hot Chocolate GraphQL server for .NET, the Strawberry Shake GraphQL client for .NET and Banana Cake Pop the awesome Monaco based GraphQL IDE.
Describe the bug
When pointing [Node]'s resolution for type T towards a method tagged with [UseFirstOrDefault] that returnsIQueryable<T>, resolution fails somewhere down in InterfaceType.CompleteAbstractTypeResolver() (presumably) because none of the types in the schema match IQueryable<T>.
To Reproduce
Code
[Node(NodeResolverType = typeof(ClientResolver), NodeResolver = "GetClient")]
public class Client
{
public int Id { get; set; }
// <snip>
}
public class ClientResolver
{
[UseFirstOrDefault, UseProjection]
public static IQueryable<Client> GetClient(int id, HotChocolate.Resolvers.IResolverContext resolverContext)
=>resolverContext.Service<IDbContextFactory<DataDbContext>>().CreateDbContext().Clients.Where(c => c.Id == id);
}
Query
{
node(id: "Q2xpZW50Cmky") {
id
}
}
Result
{
"errors": [
{
"message": "Could not resolve the actual object type from `System.String` for the abstract type `Bar`.",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"node"
]
}
],
"data": {
"node": null
}
}
Expected behavior
Expected the resolution to apply the [UseFirstOrDefault] middleware to translate the collection from IQueryable<T> to T.
Desktop (please complete the following information):
Additional context
The exact same method (GetClient()) exposed directly as the query client(id: ID!) works as expected.
The method also works as a node resolver if [UseFirstOrDefault] is removed and changed to return ...Clients.FirstOrDefaultAsync(...), but then projection is no longer possible.
I do not know if [UseProjection] would be applied if the query worked, or if that middleware is also skipped during node resolution.
In addition it appears the message resource ErrorHelper_ValueCompletion_CouldNotResolveAbstractType_Message is missing the interpolation variables. System.String and Bar are not what is supplied to it.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Describe the bug When pointing
[Node]
's resolution for typeT
towards a method tagged with[UseFirstOrDefault]
that returnsIQueryable<T>
, resolution fails somewhere down inInterfaceType.CompleteAbstractTypeResolver()
(presumably) because none of the types in the schema matchIQueryable<T>
.To Reproduce
Code
Query
Result
Expected behavior Expected the resolution to apply the
[UseFirstOrDefault]
middleware to translate the collection fromIQueryable<T>
toT
.Desktop (please complete the following information):
HotChocolate
Additional context The exact same method (
GetClient()
) exposed directly as the queryclient(id: ID!)
works as expected.The method also works as a node resolver if
[UseFirstOrDefault]
is removed and changed to return...Clients.FirstOrDefaultAsync(...)
, but then projection is no longer possible.I do not know if
[UseProjection]
would be applied if the query worked, or if that middleware is also skipped during node resolution.In addition it appears the message resource
ErrorHelper_ValueCompletion_CouldNotResolveAbstractType_Message
is missing the interpolation variables. System.String and Bar are not what is supplied to it.