LoginSignup
0
0

More than 1 year has passed since last update.

GraphQLのライブラリ「strawberry」でページネーションを定義する

Posted at

2021.12.21現在、strawberryのPaginationはcoming soonになっていました。
https://strawberry.rocks/docs/guides/pagination

image.png

現在実装に向けた取り組みが行われています。
https://github.com/strawberry-graphql/strawberry/pull/1345

暫定ですがPaginationの定義はこう書くことができます。

from typing import List, Generic, TypeVar

import strawberry


T = TypeVar("T")


@strawberry.type
class Edge(Generic[T]):
    node: T

@strawberry.type
class Connection(Generic[T]):
    edges: List[Edge[T]]
    nodes: List[T]


@strawberry.type
class Bar:
    id: int
    name: str


@strawberry.type
class Foo:
    bar: Connection[Bar]

正式リリースが待ち遠しいです。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0