Beispiel #1
0
    def test_field_with_arguments(self):
        actual = query(
            {field("user", id=4): (
                'id',
                'name',
                field("profilePic", width=100, height=50),
            )}
        )

        gql(actual)

        expected = "query { user(id: 4) { id name profilePic(height: 50, width: 100) } }"

        assert actual == expected
Beispiel #2
0
    def test_field_with_alias(self):
        actual = query(
            {field("user", id=4): (
                'id',
                'name',
                field("smallPic", "profilePic", size=64),
                field("bigPic", "profilePic", size=1024),
            )}
        )

        gql(actual)

        expected = "query { user(id: 4) { id name smallPic: profilePic(size: 64) bigPic: profilePic(size: 1024) } }"

        assert actual == expected
Beispiel #3
0
    def test_mutation_no_tuple(self):
        actual = mutation(
            {field("user", id=4, firstName="John", lastName="Doe"): (
                "ok"
            )}
        )

        gql(actual)

        expected = 'mutation { user(firstName: "John", id: 4, lastName: "Doe") { ok } }'

        assert actual == expected
Beispiel #4
0
    def test_custom_fields(self):
        actual = query(
            {field("user", id=4): (
                'firstName',
                'lastName',
                {'birthday': (
                    'month',
                    'day',
                )},
            )}
        )

        gql(actual)

        expected = "query { user(id: 4) { firstName lastName birthday { month day } } }"

        assert actual == expected
Beispiel #5
0
 def test_alias_name_and_params(self):
     assert field("alias", "name", paramOne=1) == "alias: name(paramOne: 1)"
Beispiel #6
0
 def test_name_and_params(self):
     assert field("name", paramOne=1) == "name(paramOne: 1)"
Beispiel #7
0
 def test_name_and_alias(self):
     assert field("alias", "name") == "alias: name"
Beispiel #8
0
 def test_name_only(self):
     assert field("name") == "name"