Esempio n. 1
0
        public void Convert_ObjectValue_InputObjectWithoutClrType()
        {
            // arrange
            ISchema schema = Schema.Create(c =>
            {
                c.RegisterQueryType <DummyQuery>();
                c.RegisterType(new InputObjectType(t =>
                                                   t.Name("FooInput")
                                                   .Field("a")
                                                   .Type <ListType <StringType> >()));
            });

            InputObjectType type = schema.GetType <InputObjectType>("FooInput");

            var foo = new ObjectValueNode(
                new ObjectFieldNode("a", new ListValueNode(
                                        new IValueNode[]  {
                new StringValueNode("abc"),
                new StringValueNode("def")
            })));

            // assert
            var converter = new ObjectValueToInputObjectConverter(
                DefaultTypeConverter.Default);
            object converted = converter.Convert(foo, type);

            // assert
            converted.MatchSnapshot();
        }
Esempio n. 2
0
        public void Convert_ObjectValue_FooInputObject()
        {
            // arrange
            ISchema schema = Schema.Create(c =>
            {
                c.RegisterType <InputObjectType <Foo> >();
                c.RegisterType <DecimalType>();
            });

            InputObjectType type = schema.GetType <InputObjectType>("FooInput");

            var baz = new ObjectValueNode(
                new ObjectFieldNode("number", new StringValueNode("1.5")));

            var bar = new ObjectValueNode(
                new ObjectFieldNode("state", new EnumValueNode("ON")),
                new ObjectFieldNode("bazs", new ListValueNode(baz)),
                new ObjectFieldNode("stringArray", new ListValueNode(
                                        new IValueNode[]  {
                new StringValueNode("abc"),
                new StringValueNode("def")
            })));

            var foo = new ObjectValueNode(
                new ObjectFieldNode("text", new StringValueNode("abc")),
                new ObjectFieldNode("bar", bar));

            // assert
            var converter = new ObjectValueToInputObjectConverter(
                TypeConversion.Default);
            object converted = converter.Convert(foo, type);

            // assert
            converted.Snapshot();
        }