graphql-platform
graphql-platform copied to clipboard
NodeResolver can't handle parameter names other than `id`
Is there an existing issue for this?
- [X] I have searched the existing issues
Describe the bug
When creating a node resolver you might want to use something like userId
as the parameter name of the node resolver, i.e.
[Node]
[ExtendObjectType(typeof(User))]
public class UserNode
{
[NodeResolver]
public User GetUserAsync(int userId)
{
// ...
}
}
Currently this will fail with the following error, if you issue a query with node(id: "...")
:
There was no argument with the name
userId
found on the fieldnode
.
I think we should either:
- Just inject the Id value in the first field, if it has the correct type
- We leave it like is, document that it has to be called
id
and improve the error message to point to the issue
Steps to reproduce
- Create a simple model + type extension
public class Model
{
public long Id { get; set; } = 123;
}
[Node]
[ExtendObjectType(typeof(Model))]
public class ModelNode
{
[NodeResolver]
public Model GetModelAsync(long serial)
{
// ...
}
}
- Issue a query like the following
{
node(id: "TW9kZWwKbDEyMw==") {
id
}
}
- You receive the following error:
There was no argument with the name
serial
found on the fieldnode
.
Relevant log output
No response
Additional Context?
No response
Product
Hot Chocolate
Version
12.4.0-preview.14