コード例 #1
0
        public void CreateQuery_RequestForComplexObjectWithExernalParamsInObject_GeneratesCorrectQuery()
        {
            var client = new TestClient(null);

            var input = new
            {
                test1  = "test1",
                others = new
                {
                    test2  = "test2",
                    others = new
                    {
                        test3  = "test3",
                        others = new
                        {
                            test4 = "test4"
                        }
                    }
                }
            };

            var query = client.CreateQuery(e => new
            {
                o = e.ComplexWithParams(input.test1).Test,
                b = e.ComplexWithParams(input.others.others.others.test4).Complex.ComplexWithParams(input.others.test2).Complex.Test,
                c = e.ComplexWithParams(input.test1).ComplexWithParams(input.others.others.test3).Simple.Test
            });

            AssertUtils.AreEqualIgnoreLineBreaks(@"query Query($var_0: String!, $var_1: String!, $var_2: String!, $var_3: String!) {
  field0: complexWithParams(name: $var_0){
    field0: test
    field1: complexWithParams(name: $var_1){
      field0: simple{
        field0: test
        __typename
      }
      __typename
    }
    __typename
  }
  field1: complexWithParams(name: $var_2){
    field0: complex{
      field0: complexWithParams(name: $var_3){
        field0: complex{
          field0: test
          __typename
        }
        __typename
      }
      __typename
    }
    __typename
  }
  __typename
}", query.Query);

            Assert.AreEqual("test1", query.Variables["var_0"]);
            Assert.AreEqual("test3", query.Variables["var_1"]);
            Assert.AreEqual("test4", query.Variables["var_2"]);
            Assert.AreEqual("test2", query.Variables["var_3"]);
        }