public string Print(GraphType type) { if (_schemaPrinter == null) { _schemaPrinter = new SchemaPrinter(Schema); } return _schemaPrinter.ResolveName(type); }
public void build_dynamic_schema() { var schema = new Schema(); var person = new ObjectGraphType(); person.Name = "Person"; person.Field("name", new StringGraphType()); person.Field( "friends", new ListGraphType(new NonNullGraphType(person)), resolve: ctx => new[] {new SomeObject {Name = "Jaime"}, new SomeObject {Name = "Joe"}}); var root = new ObjectGraphType(); root.Name = "Root"; root.Field("hero", person, resolve: ctx => ctx.RootValue); schema.Query = root; schema.RegisterTypes(person); var printed = new SchemaPrinter(schema).Print(); #if DEBUG Console.WriteLine(printed); #endif AssertQuerySuccess( schema, @"{ hero { name friends { name } } }", @"{ hero: { name : 'Quinn', friends: [ { name: 'Jaime' }, { name: 'Joe' }] } }", root: new SomeObject { Name = "Quinn"}); }