Ejemplo n.º 1
0
 def fields():
     return {
         "id": field(column_name="id", type=GraphQLInt),
         "title": field(column_name="title", type=GraphQLString),
         "genre": field(column_name="genre", type=GraphQLString),
         "authorId": field(column_name="author_id", type=GraphQLInt),
         "author": single(author_join_type, author_query, join={"authorId": "id"}),
     }
Ejemplo n.º 2
0
 def fields():
     books = many(
         book_join_type,
         lambda *_: all_books,
         join={"id": "authorId"},
     )
     return {
         "id": field(attr="id", type=GraphQLInt),
         "name": field(attr="name", type=GraphQLString),
         "books": books,
         "bookTitles": extract(books, "title"),
     }
Ejemplo n.º 3
0
    def fields():
        books = many(
            book_join_type,
            book_query,
            join={"id": "authorId"},
        )

        return {
            "id": field(column_name="id", type=GraphQLInt),
            "name": field(column_name="name", type=GraphQLString),
            "books": books,
            "bookTitles": extract(books, "title"),
        }
Ejemplo n.º 4
0
    def fields():
        author = single(
            author_join_type,
            lambda *_: all_authors,
            join={"authorId": "id"},
        )

        return {
            "id": field(attr="id", type=GraphQLInt),
            "title": field(attr="title", type=GraphQLString),
            "authorId": field(attr="author_id", type=GraphQLInt),
            "author": author,
            "booksBySameAuthor": extract(author, "books"),
        }
Ejemplo n.º 5
0
    def fields():
        author = single(
            author_join_type,
            author_query,
            join={"authorId": "id"},
        )

        return {
            "id": field(column_name="id", type=GraphQLInt),
            "title": field(column_name="title", type=GraphQLString),
            "authorId": field(column_name="author_id", type=GraphQLInt),
            "author": author,
            "booksBySameAuthor": extract(author, "books"),
        }
Ejemplo n.º 6
0
def test_args_are_set_on_graphql_field():
    field = graphjoiner.field(
        args={"format": GraphQLString},
        type=GraphQLString,
    )

    assert_that(field.to_graphql_field().args, has_key("format"))
Ejemplo n.º 7
0
def test_join_types_are_not_nullable():
    object_type = JoinType(
        name="Object",
        fields=lambda: {"id": field(type=GraphQLInt)},
        fetch_immediates=None,
    )

    graphql_type = object_type.to_graphql_type()
    assert_that(
        graphql_type,
        is_non_null(
            is_object_type(fields=has_entries({
                "id": is_field(type=is_int),
            }), )))
Ejemplo n.º 8
0
 def instantiate(self):
     type_ = _to_graphql_core_type(self.type)
     return graphjoiner.field(type=type_, **self._kwargs)
Ejemplo n.º 9
0
 def fields():
     return {
         "id": field(column_name="id", type=GraphQLInt),
         "name": field(column_name="name", type=GraphQLString),
     }