Example #1
0
    class Author(StaticDataObjectType):
        __records__ = [
            AuthorRecord("PGW", "PG Wodehouse"),
            AuthorRecord("JH", "Joseph Heller"),
        ]

        id = field(type=String)
        name = field(type=String)
class Sales(ObjectType):
    book_title = field(property_name="title", type=GraphQLString)
    quantity = field(property_name="quantity", type=GraphQLInt)

    @staticmethod
    def __fetch_immediates__(selections, values, context):
        sales = context.api.fetch_sales(
            titles=[value.book_title for value in values])
        return (tuple(sale[selection.field.property_name]
                      for selection in selections) for sale in sales)
Example #3
0
    class Book(StaticDataObjectType):
        __records__ = [
            BookRecord("PGW", "Leave it to Psmith"),
            BookRecord("PGW", "The Code of the Woosters"),
        ]

        author_id = field(type=String, internal=True)
        author = single(lambda: StaticDataObjectType.select(
            Author,
            join={Book.author_id: Author.id},
        ))
        title = field(type=String)
    class Author(StaticDataObjectType):
        __records__ = [
            AuthorRecord("PG Wodehouse"),
            AuthorRecord("Joseph Heller"),
        ]

        name = field(type=GraphQLString)
Example #5
0
    class Author(ObjectType, DictQuery):
        __records__ = [
            AuthorRecord("PG Wodehouse"),
            AuthorRecord("Joseph Heller"),
        ]

        name = field(type=String)

        @classmethod
        def __fetch_immediates__(cls, selections, query, context):
            records = cls.__records__
            if "nameStartsWith" in query:
                prefix = query["nameStartsWith"]
                records = list(
                    filter(
                        lambda record: record.name.startswith(prefix),
                        records,
                    ))

            return [
                tuple(
                    getattr(record, selection.field.attr_name)
                    for selection in selections) for record in records
            ]
Example #6
0
 class Book(StaticDataObjectType):
     __records__ = []
     title = field(type=String)
Example #7
0
 class AuthorSelection(InputObjectType):
     limit = field(type=Int, default=None)
     name = field(type=String, default=None)
Example #8
0
 class AuthorSelection(InputObjectType):
     name = field(type=String)
Example #9
0
 class BookSelection(InputObjectType):
     author_selection = field(type=AuthorSelection)
Example #10
0
 class AuthorSelection(InputObjectType):
     names = field(type=List(String))
Example #11
0
 class SelectionInput(InputObjectType):
     name = field(type=String)
Example #12
0
 class Author(InterfaceType):
     name = field(type=String)
Example #13
0
 class HasName(InterfaceType):
     name = field(type=String)
Example #14
0
    class Author(StaticDataObjectType):
        __interfaces__ = lambda: [HasName]

        __records__ = [AuthorRecord("PG Wodehouse")]

        name = field(type=String)
Example #15
0
 class Author(StaticDataObjectType):
     name = field(type=String)
Example #16
0
 class Root(RootType):
     value_b = field(type=Int)
     value_a = field(type=Int)
     value_c = field(type=Int)
Example #17
0
 class UserInput(InputObjectType):
     username = field(type=String)
     email_address = field(type=String)
Example #18
0
    class Author(StaticDataObjectType):
        __records__ = [AuthorRecord("PG Wodehouse")]

        name = field(type=String)
Example #19
0
    class Book(StaticDataObjectType):
        __records__ = [BookRecord("Leave it to Psmith")]

        title = field(type=String)
Example #20
0
 class Book(InterfaceType):
     author = field(type=Author)
Example #21
0
 class Named(object):
     name = field(type=String)
Example #22
0
 class Book(InterfaceType):
     author = field(type=lambda: Author)
Example #23
0
    class Selection(StaticDataObjectType):
        __records__ = []

        name = field(type=String)
Example #24
0
    class Author(ObjectType):
        name = field(type=String)

        def __fetch_immediates__(cls, selections, query, context):
            pass
Example #25
0
 class BookSelection(InputObjectType):
     author_selections = field(type=List(AuthorSelection))
Example #26
0
 class BoxFields(object):
     value = field(type=GraphQLInt)
Example #27
0
 class AuthorSelection(InputObjectType):
     name_starts_with = field(type=String)
Example #28
0
 class Author(StaticDataObjectType):
     __records__ = []
     name = field(type=String)
Example #29
0
 class Range(InputObjectType):
     start = field(type=Int)
     end = field(type=Int)
Example #30
0
    class GeneratedType(InputObjectType):
        __name__ = "User"

        email_address = field(type=String)
        __fetch_immediates__ = None