| 4975 | } |
| 4976 | |
| 4977 | func TestParseGraphQLVarPaginationRoot(t *testing.T) { |
| 4978 | for _, q := range []string{ |
| 4979 | "query test($a: int = 2){ q(func: uid(0x1), first: $a) { name }}", |
| 4980 | "query test($a: int = 2){ q(func: uid(0x1), offset: $a) { name }}", |
| 4981 | "query test($a: int = 2){ q(func: uid(0x1), orderdesc: name, first: $a) { name }}", |
| 4982 | "query test($a: int = 2){ q(func: uid(0x1), orderdesc: name, offset: $a) { name }}", |
| 4983 | "query test($a: int = 2){ q(func: eq(name, \"abc\"), orderdesc: name, first: $a) { name }}", |
| 4984 | "query test($a: int = 2){ q(func: eq(name, \"abc\"), orderdesc: name, offset: $a) { name }}", |
| 4985 | } { |
| 4986 | r := Request{ |
| 4987 | Str: q, |
| 4988 | Variables: map[string]string{"$a": "3"}, |
| 4989 | } |
| 4990 | gq, err := Parse(r) |
| 4991 | t.Log(q) |
| 4992 | t.Log(err) |
| 4993 | require.NoError(t, err) |
| 4994 | args := gq.Query[0].Args |
| 4995 | require.True(t, args["first"] == "3" || args["offset"] == "3") |
| 4996 | } |
| 4997 | } |
| 4998 | |
| 4999 | func TestParseGraphQLVarPaginationChild(t *testing.T) { |
| 5000 | for _, q := range []string{ |