0

Based on an example from graphql-dotnet :

public class Droid
{
    public string Id { get; set; }
    public string Name { get; set; }
}

public class Query
{
    [GraphQLMetadata("hero")]
    public Droid GetHero()
    {
        return new Droid { Id = "123", Name = "R2-D2" };
    }
}

var schema = Schema.For(@"
  interface Node {
    id: String
  }
  type Droid implements Node {
    id: String
    name: String
  }

  type Query {
    hero: Node
  }
", _ => {
    _.Types.Include<Query>();
});

var result = schema.Execute(_ =>
{
  _.Query = "{ hero { id ... on Droid { name } } }";
});

I need to define ResolveType method for interface Node. I found this way:

_.Types.For("Node").ResolveType = obj => { /* needs to return an ObjectGraphType object here */ };

the ResolveType gets a Droid object as input, but it needs an ObjectGraphType object! In NodeJS I could just return the resolved type as string like "Droid".

Is there any work around, without defining new classes inheriting from ObjectGraphType?

Majid
  • 3,128
  • 1
  • 26
  • 31

1 Answers1

0

The solution is discussed here: https://github.com/graphql-dotnet/graphql-dotnet/issues/593

Majid
  • 3,128
  • 1
  • 26
  • 31