zf

zenflows testing
git clone https://s.sonu.ch/~srfsh/zf.git
Log | Files | Refs | Submodules | README | LICENSE

commit 8d485f19dee658027f8fe50fd177ad71929e8cac
parent 2b2205498c53be7cc23f0d0d3a4f5ea276be7efb
Author: srfsh <dev@srf.sh>
Date:   Sun, 14 Aug 2022 13:30:05 +0300

Zenflows.GQL.Type: add :page_info type

This will be useful when we implement paging.

Diffstat:
Msrc/zenflows/gql/type.ex | 43+++++++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+), 0 deletions(-)

diff --git a/src/zenflows/gql/type.ex b/src/zenflows/gql/type.ex @@ -35,6 +35,49 @@ scalar :base64, name: "Base64" do serialize & &1 end +@desc "Cursors for pagination" +object :page_info do + @desc """ + Cursor pointing to the first of the results returned, to be + used with `before` query parameter if the backend supports + reverse pagination. + """ + field :start_cursor, :id + + @desc """ + Cursor pointing to the last of the results returned, to be used + with `after` query parameter if the backend supports forward + pagination. + """ + field :end_cursor, :id + + @desc """ + True if there are more results before `startCursor`. If unable + to be determined, implementations should return `true` to allow + for requerying. + """ + field :has_previous_page, non_null(:boolean) + + @desc """ + True if there are more results after `endCursor`. If unable + to be determined, implementations should return `true` to allow + for requerying. + """ + field :has_next_page, non_null(:boolean) + + @desc "The total result count, if it can be determined." + field :total_count, :integer + + @desc """ + The number of items requested per page. Allows the storage + backend to indicate this when it is responsible for setting a + default and the client does not provide it. Note this may be + different to the number of items returned, if there is less than + 1 page of results. + """ + field :page_limit, :integer +end + # TODO: Decide whether we really want these to be valid URIs or just # Strings. @spec uri_parse(Input.t()) :: {:ok, String.t() | nil} | :error