Beispiel #1
0
 public void throw_error_on_null_with_register_types()
 {
     var schema = new Schema();
     Expect.Throws<ArgumentNullException>(() => schema.RegisterTypes(null));
 }
        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"});
        }
Beispiel #3
0
 public void throw_error_on_non_graphtype_with_register_types()
 {
     var schema = new Schema();
     Expect.Throws<ArgumentOutOfRangeException>(() => schema.RegisterTypes(typeof(MyDto)));
 }
 public void throw_error_on_null_with_register_types()
 {
     var schema = new Schema();
     Type[] types = null;
     Should.Throw<ArgumentNullException>(() => schema.RegisterTypes(types));
 }