graphql-dotnet / graphql-dotnet/relay
Dependency Injection
- Dominant language
- C#
- Stars
- 74
- Forks
- 28
- PR merge metrics
- No merged PRs in 30d
Description
I am having a hard time figuring out how you get StarWarsData into the DroidType class.
public class Droid
{
public string DroidId { get; set; }
public string Name { get; set; }
}
public class DroidType : NodeGraphType
{
public DroidType()
{
Name = "Droid";
Id(d => d.DroidId); // adds an id Field as well as the `Droid` id field
Field("name", "The name of the droid.");
}
public override Droid GetById(string droidId) {
return **StarWarsData.GetDroidByIdAsync(droidId);**
}
}
I started my project by following the pattern that Jacek Kosciesza did in his StarWars example [https://github.com/JacekKosciesza/StarWars] and I was able to get dependency injection to work in my ModelType (i.e. DroidType classes).
However, I am trying to get my project to work with React / Relay, so I wanted to change my server to follow that specification. I found your library and started to refactor things. When I changed my RootQuery to inherit from QueryGraphType, I receive the error:
"Cannot return null for non-null type. Field: type, Type: __Type!."
"stackTrace": " at GraphQL.DocumentExecuter.d__14.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at GraphQL.DocumentExecuter.d__12.MoveNext()",
I'm hoping you have some ideas on how I can get past this.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.