class Book(SqlAlchemyObjectType): __model__ = BookRecord id = column_field(column=BookRecord.c_id) title = column_field(column=BookRecord.c_title) author_id = column_field(column=BookRecord.c_author_id) author = single(lambda: sql_join(Author)) books_by_same_author = extract(author, "books") sales = single( lambda: sql_value_join(Sales, {Book.title: Sales.book_title}))
class Root(RootType): books = many(lambda: select(Book)) book = single(lambda: select(Book)) @book.arg("id", GraphQLInt) def book_id(query, book_id): return query.filter(BookRecord.c_id == book_id) author = single(lambda: select(Author)) @author.arg("id", GraphQLInt) def author_id(query, author_id): return query.filter(AuthorRecord.c_id == author_id)
class Root(RootType): author = single( lambda: select(Author), args={ "nameStartsWith": String, }, )
class Book(SqlAlchemyObjectType): __model__ = BookRecord id = column_field(BookRecord.id) title = column_field(BookRecord.title) genre = column_field(BookRecord.genre) author_id = column_field(BookRecord.author_id) author = single(lambda: sql_join(Author))
class Root(RootType): author = single(lambda: StaticDataObjectType.select(Author)) @author.arg("nameStartsWith", Boolean) def author_arg_starts_with(records, _, context): return list( filter( lambda record: record.name.startswith(context), records, ))
class Root(RootType): author = single(lambda: StaticDataObjectType.select(Author)) @author.arg("nameStartsWith", String) def author_arg_starts_with(records, prefix): return list( filter( lambda record: record.name.startswith(prefix), records, ))
class Root(RootType): author = single(lambda: StaticDataObjectType.select(Author)) @author.arg("selection", AuthorSelection) def author_arg_selection(records, selection): return list( filter( lambda record: record.name.startswith(selection. name_starts_with), records, ))
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 Root(RootType): author = single(lambda: self._join_to_authors(count=2))
class Root(RootType): selection = single(lambda: StaticDataObjectType.select(Selection)) @selection.arg("selection", SelectionInput) def selection_arg_selection(records, selection): return [SelectionRecord(str(selection.name))]
class Root(RootType): author = single(lambda: StaticDataObjectType.select(Author))
class Root(RootType): fields = field_set( author=single(lambda: StaticDataObjectType.select(Author)), book=single(lambda: StaticDataObjectType.select(Book)), )
class Root(RootType): box = single(lambda: select(Box))