0

I am just starting in GraphQL (with .NET, but I don't think that matters here). I have learned how to pass variables that are properties of the type I am querying, but I am not sure how to pass variables that are NOT properties.

For example, I have a database full of Drivers, who all belong to 1 or more Client. Driver object does NOT have a ClientId property. Instead, there is a Client object with 0 or more Driver objects.

Driver.cs:

public class Driver
{
    public long Id { get; set; }
    public string FirstName { get; set; }
    public string LastName { get; set; }
}

In RootQuery constructor:

Field<ListGraphType<DriverGraph>>(
    name: "clientDrivers",
    arguments: new QueryArguments(
        new QueryArgument<IntGraphType> { Name = "clientId" }),
    resolve: context => driverRepo.GetClientDrivers(context.GetArgument<long>("clientId"))
);

Is this possible? Or do I have to either a) add a ClientId property to my driver object, or b) implement a "ClientGraph" object?

Thanks!

Daniel Rearden
  • 80,636
  • 11
  • 185
  • 183
emery.noel
  • 1,073
  • 1
  • 9
  • 24

1 Answers1

0

And .... never mind. I figured it out, it's not a problem. I wasn't calling "clientDrivers" in the above code, I was calling "drivers".

Sorry about that!

emery.noel
  • 1,073
  • 1
  • 9
  • 24