Skip to content

Commit

Permalink
feat: add order
Browse files Browse the repository at this point in the history
  • Loading branch information
hUwUtao committed Nov 28, 2024
1 parent 1cabf47 commit cff1c6c
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@team-fuho/wt",
"version": "2.1.1",
"version": "2.1.2",
"description": "powered by `wagtail`. awesome!",
"type": "module",
"main": "dist/index.js",
Expand Down
22 changes: 18 additions & 4 deletions src/client.gql
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,17 @@ query GalleryListView {
}
}

query GalleryPaginatedListView($offset: PositiveInt, $limit: PositiveInt) {
pages(contentType: "gallery.Picture", offset: $offset, limit: $limit) {
query GalleryPaginatedListView(
$offset: PositiveInt
$limit: PositiveInt
$order: String
) {
pages(
contentType: "gallery.Picture"
offset: $offset
limit: $limit
order: $order
) {
...GalleryOuterView
}
}
Expand All @@ -76,8 +85,13 @@ query BlogListView {
}
}

query BlogPaginatedListView($offset: PositiveInt, $limit: PositiveInt) {
pages(contentType: "blog.BlogPage", offset: $offset, limit: $limit) {
query BlogPaginatedListView($offset: PositiveInt, $limit: PositiveInt, $order: String) {
pages(
contentType: "blog.BlogPage"
offset: $offset
limit: $limit
order: $order
) {
...BlogPageOuterView
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/graphql/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ import * as types from './graphql';
* Learn more about it here: https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#reducing-bundle-size
*/
const documents = {
"fragment DefaultImageView on TFImage {\n id\n url\n rendition(width: 1200, height: 630, format: \"jpeg\", jpegquality: 85) {\n id\n url\n width\n height\n }\n srcSet(sizes: [768, 1080], format: \"webp\")\n width\n height\n}\n\nfragment BlogPageOuterView on BlogPage {\n id\n slug\n title\n seoTitle\n thumb {\n ...DefaultImageView\n }\n}\n\nfragment BlogPageInnerView on BlogPage {\n body {\n ... on StreamFieldInterface {\n blockType\n }\n ... on RichTextBlock {\n value\n }\n ... on ImageBlock {\n caption\n link\n alignment\n image {\n ...DefaultImageView\n }\n }\n ... on QuoteBlock {\n quote\n attribution\n }\n ... on HeadingBlock {\n text\n importance\n }\n }\n}\n\nfragment GalleryOuterView on Picture {\n id\n cap\n image {\n ...DefaultImageView\n }\n imageDate\n}\n\nquery GalleryListView {\n pages(contentType: \"gallery.Picture\") {\n ...GalleryOuterView\n }\n}\n\nquery GalleryPaginatedListView($offset: PositiveInt, $limit: PositiveInt) {\n pages(contentType: \"gallery.Picture\", offset: $offset, limit: $limit) {\n ...GalleryOuterView\n }\n}\n\nquery BlogListView {\n pages(contentType: \"blog.BlogPage\") {\n ...BlogPageOuterView\n }\n}\n\nquery BlogPaginatedListView($offset: PositiveInt, $limit: PositiveInt) {\n pages(contentType: \"blog.BlogPage\", offset: $offset, limit: $limit) {\n ...BlogPageOuterView\n }\n}\n\nquery BlogPreviewView($token: String) {\n page(id: 0, token: $token) {\n ...BlogPageOuterView\n ...BlogPageInnerView\n }\n}\n\nquery BlogLiveView($slug: String) {\n page(slug: $slug) {\n ...BlogPageOuterView\n ...BlogPageInnerView\n }\n}": types.DefaultImageViewFragmentDoc,
"fragment DefaultImageView on TFImage {\n id\n url\n rendition(width: 1200, height: 630, format: \"jpeg\", jpegquality: 85) {\n id\n url\n width\n height\n }\n srcSet(sizes: [768, 1080], format: \"webp\")\n width\n height\n}\n\nfragment BlogPageOuterView on BlogPage {\n id\n slug\n title\n seoTitle\n thumb {\n ...DefaultImageView\n }\n}\n\nfragment BlogPageInnerView on BlogPage {\n body {\n ... on StreamFieldInterface {\n blockType\n }\n ... on RichTextBlock {\n value\n }\n ... on ImageBlock {\n caption\n link\n alignment\n image {\n ...DefaultImageView\n }\n }\n ... on QuoteBlock {\n quote\n attribution\n }\n ... on HeadingBlock {\n text\n importance\n }\n }\n}\n\nfragment GalleryOuterView on Picture {\n id\n cap\n image {\n ...DefaultImageView\n }\n imageDate\n}\n\nquery GalleryListView {\n pages(contentType: \"gallery.Picture\") {\n ...GalleryOuterView\n }\n}\n\nquery GalleryPaginatedListView($offset: PositiveInt, $limit: PositiveInt, $order: String) {\n pages(\n contentType: \"gallery.Picture\"\n offset: $offset\n limit: $limit\n order: $order\n ) {\n ...GalleryOuterView\n }\n}\n\nquery BlogListView {\n pages(contentType: \"blog.BlogPage\") {\n ...BlogPageOuterView\n }\n}\n\nquery BlogPaginatedListView($offset: PositiveInt, $limit: PositiveInt, $order: String) {\n pages(\n contentType: \"blog.BlogPage\"\n offset: $offset\n limit: $limit\n order: $order\n ) {\n ...BlogPageOuterView\n }\n}\n\nquery BlogPreviewView($token: String) {\n page(id: 0, token: $token) {\n ...BlogPageOuterView\n ...BlogPageInnerView\n }\n}\n\nquery BlogLiveView($slug: String) {\n page(slug: $slug) {\n ...BlogPageOuterView\n ...BlogPageInnerView\n }\n}": types.DefaultImageViewFragmentDoc,
};

/**
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
*/
export function graphql(source: "fragment DefaultImageView on TFImage {\n id\n url\n rendition(width: 1200, height: 630, format: \"jpeg\", jpegquality: 85) {\n id\n url\n width\n height\n }\n srcSet(sizes: [768, 1080], format: \"webp\")\n width\n height\n}\n\nfragment BlogPageOuterView on BlogPage {\n id\n slug\n title\n seoTitle\n thumb {\n ...DefaultImageView\n }\n}\n\nfragment BlogPageInnerView on BlogPage {\n body {\n ... on StreamFieldInterface {\n blockType\n }\n ... on RichTextBlock {\n value\n }\n ... on ImageBlock {\n caption\n link\n alignment\n image {\n ...DefaultImageView\n }\n }\n ... on QuoteBlock {\n quote\n attribution\n }\n ... on HeadingBlock {\n text\n importance\n }\n }\n}\n\nfragment GalleryOuterView on Picture {\n id\n cap\n image {\n ...DefaultImageView\n }\n imageDate\n}\n\nquery GalleryListView {\n pages(contentType: \"gallery.Picture\") {\n ...GalleryOuterView\n }\n}\n\nquery GalleryPaginatedListView($offset: PositiveInt, $limit: PositiveInt) {\n pages(contentType: \"gallery.Picture\", offset: $offset, limit: $limit) {\n ...GalleryOuterView\n }\n}\n\nquery BlogListView {\n pages(contentType: \"blog.BlogPage\") {\n ...BlogPageOuterView\n }\n}\n\nquery BlogPaginatedListView($offset: PositiveInt, $limit: PositiveInt) {\n pages(contentType: \"blog.BlogPage\", offset: $offset, limit: $limit) {\n ...BlogPageOuterView\n }\n}\n\nquery BlogPreviewView($token: String) {\n page(id: 0, token: $token) {\n ...BlogPageOuterView\n ...BlogPageInnerView\n }\n}\n\nquery BlogLiveView($slug: String) {\n page(slug: $slug) {\n ...BlogPageOuterView\n ...BlogPageInnerView\n }\n}"): typeof import('./graphql').DefaultImageViewFragmentDoc;
export function graphql(source: "fragment DefaultImageView on TFImage {\n id\n url\n rendition(width: 1200, height: 630, format: \"jpeg\", jpegquality: 85) {\n id\n url\n width\n height\n }\n srcSet(sizes: [768, 1080], format: \"webp\")\n width\n height\n}\n\nfragment BlogPageOuterView on BlogPage {\n id\n slug\n title\n seoTitle\n thumb {\n ...DefaultImageView\n }\n}\n\nfragment BlogPageInnerView on BlogPage {\n body {\n ... on StreamFieldInterface {\n blockType\n }\n ... on RichTextBlock {\n value\n }\n ... on ImageBlock {\n caption\n link\n alignment\n image {\n ...DefaultImageView\n }\n }\n ... on QuoteBlock {\n quote\n attribution\n }\n ... on HeadingBlock {\n text\n importance\n }\n }\n}\n\nfragment GalleryOuterView on Picture {\n id\n cap\n image {\n ...DefaultImageView\n }\n imageDate\n}\n\nquery GalleryListView {\n pages(contentType: \"gallery.Picture\") {\n ...GalleryOuterView\n }\n}\n\nquery GalleryPaginatedListView($offset: PositiveInt, $limit: PositiveInt, $order: String) {\n pages(\n contentType: \"gallery.Picture\"\n offset: $offset\n limit: $limit\n order: $order\n ) {\n ...GalleryOuterView\n }\n}\n\nquery BlogListView {\n pages(contentType: \"blog.BlogPage\") {\n ...BlogPageOuterView\n }\n}\n\nquery BlogPaginatedListView($offset: PositiveInt, $limit: PositiveInt, $order: String) {\n pages(\n contentType: \"blog.BlogPage\"\n offset: $offset\n limit: $limit\n order: $order\n ) {\n ...BlogPageOuterView\n }\n}\n\nquery BlogPreviewView($token: String) {\n page(id: 0, token: $token) {\n ...BlogPageOuterView\n ...BlogPageInnerView\n }\n}\n\nquery BlogLiveView($slug: String) {\n page(slug: $slug) {\n ...BlogPageOuterView\n ...BlogPageInnerView\n }\n}"): typeof import('./graphql').DefaultImageViewFragmentDoc;


export function graphql(source: string) {
Expand Down
24 changes: 18 additions & 6 deletions src/graphql/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1202,6 +1202,7 @@ export type GalleryListViewQuery = { __typename?: 'Query', pages: Array<{ __type
export type GalleryPaginatedListViewQueryVariables = Exact<{
offset?: InputMaybe<Scalars['PositiveInt']['input']>;
limit?: InputMaybe<Scalars['PositiveInt']['input']>;
order?: InputMaybe<Scalars['String']['input']>;
}>;


Expand All @@ -1215,6 +1216,7 @@ export type BlogListViewQuery = { __typename?: 'Query', pages: Array<{ __typenam
export type BlogPaginatedListViewQueryVariables = Exact<{
offset?: InputMaybe<Scalars['PositiveInt']['input']>;
limit?: InputMaybe<Scalars['PositiveInt']['input']>;
order?: InputMaybe<Scalars['String']['input']>;
}>;


Expand Down Expand Up @@ -1376,8 +1378,13 @@ fragment GalleryOuterView on Picture {
imageDate
}`, {"hash":"bc73a1301295701b7bb12544d5a516c075d827bc"}) as unknown as TypedDocumentString<GalleryListViewQuery, GalleryListViewQueryVariables>;
export const GalleryPaginatedListViewDocument = new TypedDocumentString(`
query GalleryPaginatedListView($offset: PositiveInt, $limit: PositiveInt) {
pages(contentType: "gallery.Picture", offset: $offset, limit: $limit) {
query GalleryPaginatedListView($offset: PositiveInt, $limit: PositiveInt, $order: String) {
pages(
contentType: "gallery.Picture"
offset: $offset
limit: $limit
order: $order
) {
...GalleryOuterView
}
}
Expand All @@ -1401,7 +1408,7 @@ fragment GalleryOuterView on Picture {
...DefaultImageView
}
imageDate
}`, {"hash":"e2352450c578778cd6463ff762ae20b7665a654a"}) as unknown as TypedDocumentString<GalleryPaginatedListViewQuery, GalleryPaginatedListViewQueryVariables>;
}`, {"hash":"263a1a0d428bf9f7b4341fcb405542b77c7f7765"}) as unknown as TypedDocumentString<GalleryPaginatedListViewQuery, GalleryPaginatedListViewQueryVariables>;
export const BlogListViewDocument = new TypedDocumentString(`
query BlogListView {
pages(contentType: "blog.BlogPage") {
Expand Down Expand Up @@ -1431,8 +1438,13 @@ fragment BlogPageOuterView on BlogPage {
}
}`, {"hash":"e1c027ed6403289772d00fc4ab20cbb715d56dd8"}) as unknown as TypedDocumentString<BlogListViewQuery, BlogListViewQueryVariables>;
export const BlogPaginatedListViewDocument = new TypedDocumentString(`
query BlogPaginatedListView($offset: PositiveInt, $limit: PositiveInt) {
pages(contentType: "blog.BlogPage", offset: $offset, limit: $limit) {
query BlogPaginatedListView($offset: PositiveInt, $limit: PositiveInt, $order: String) {
pages(
contentType: "blog.BlogPage"
offset: $offset
limit: $limit
order: $order
) {
...BlogPageOuterView
}
}
Expand All @@ -1457,7 +1469,7 @@ fragment BlogPageOuterView on BlogPage {
thumb {
...DefaultImageView
}
}`, {"hash":"c6a0990827dbca5252022baf9f074ed2d40c8167"}) as unknown as TypedDocumentString<BlogPaginatedListViewQuery, BlogPaginatedListViewQueryVariables>;
}`, {"hash":"3335902d4991e2a90f463cad36363e644ad5c2d6"}) as unknown as TypedDocumentString<BlogPaginatedListViewQuery, BlogPaginatedListViewQueryVariables>;
export const BlogPreviewViewDocument = new TypedDocumentString(`
query BlogPreviewView($token: String) {
page(id: 0, token: $token) {
Expand Down
4 changes: 2 additions & 2 deletions src/graphql/persisted-documents.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"bc73a1301295701b7bb12544d5a516c075d827bc": "fragment DefaultImageView on TFImage { height id rendition(width: 1200, height: 630, format: \"jpeg\", jpegquality: 85) { height id url width } srcSet(sizes: [768, 1080], format: \"webp\") url width } fragment GalleryOuterView on Picture { cap id image { ...DefaultImageView } imageDate } query GalleryListView { pages(contentType: \"gallery.Picture\") { ...GalleryOuterView } }",
"e2352450c578778cd6463ff762ae20b7665a654a": "fragment DefaultImageView on TFImage { height id rendition(width: 1200, height: 630, format: \"jpeg\", jpegquality: 85) { height id url width } srcSet(sizes: [768, 1080], format: \"webp\") url width } fragment GalleryOuterView on Picture { cap id image { ...DefaultImageView } imageDate } query GalleryPaginatedListView($limit: PositiveInt, $offset: PositiveInt) { pages(contentType: \"gallery.Picture\", offset: $offset, limit: $limit) { ...GalleryOuterView } }",
"263a1a0d428bf9f7b4341fcb405542b77c7f7765": "fragment DefaultImageView on TFImage { height id rendition(width: 1200, height: 630, format: \"jpeg\", jpegquality: 85) { height id url width } srcSet(sizes: [768, 1080], format: \"webp\") url width } fragment GalleryOuterView on Picture { cap id image { ...DefaultImageView } imageDate } query GalleryPaginatedListView($limit: PositiveInt, $offset: PositiveInt, $order: String) { pages( contentType: \"gallery.Picture\" offset: $offset limit: $limit order: $order ) { ...GalleryOuterView } }",
"e1c027ed6403289772d00fc4ab20cbb715d56dd8": "fragment BlogPageOuterView on BlogPage { id seoTitle slug thumb { ...DefaultImageView } title } fragment DefaultImageView on TFImage { height id rendition(width: 1200, height: 630, format: \"jpeg\", jpegquality: 85) { height id url width } srcSet(sizes: [768, 1080], format: \"webp\") url width } query BlogListView { pages(contentType: \"blog.BlogPage\") { ...BlogPageOuterView } }",
"c6a0990827dbca5252022baf9f074ed2d40c8167": "fragment BlogPageOuterView on BlogPage { id seoTitle slug thumb { ...DefaultImageView } title } fragment DefaultImageView on TFImage { height id rendition(width: 1200, height: 630, format: \"jpeg\", jpegquality: 85) { height id url width } srcSet(sizes: [768, 1080], format: \"webp\") url width } query BlogPaginatedListView($limit: PositiveInt, $offset: PositiveInt) { pages(contentType: \"blog.BlogPage\", offset: $offset, limit: $limit) { ...BlogPageOuterView } }",
"3335902d4991e2a90f463cad36363e644ad5c2d6": "fragment BlogPageOuterView on BlogPage { id seoTitle slug thumb { ...DefaultImageView } title } fragment DefaultImageView on TFImage { height id rendition(width: 1200, height: 630, format: \"jpeg\", jpegquality: 85) { height id url width } srcSet(sizes: [768, 1080], format: \"webp\") url width } query BlogPaginatedListView($limit: PositiveInt, $offset: PositiveInt, $order: String) { pages( contentType: \"blog.BlogPage\" offset: $offset limit: $limit order: $order ) { ...BlogPageOuterView } }",
"3b58296f25c4263c58bc4877c22469d789da26d6": "fragment BlogPageInnerView on BlogPage { body { ... on HeadingBlock { importance text } ... on ImageBlock { alignment caption image { ...DefaultImageView } link } ... on QuoteBlock { attribution quote } ... on RichTextBlock { value } ... on StreamFieldInterface { blockType } } } fragment BlogPageOuterView on BlogPage { id seoTitle slug thumb { ...DefaultImageView } title } fragment DefaultImageView on TFImage { height id rendition(width: 1200, height: 630, format: \"jpeg\", jpegquality: 85) { height id url width } srcSet(sizes: [768, 1080], format: \"webp\") url width } query BlogPreviewView($token: String) { page(id: 0, token: $token) { ...BlogPageInnerView ...BlogPageOuterView } }",
"1ef7624b0c89de8f5c7007e299ef6b4e9f1ebb13": "fragment BlogPageInnerView on BlogPage { body { ... on HeadingBlock { importance text } ... on ImageBlock { alignment caption image { ...DefaultImageView } link } ... on QuoteBlock { attribution quote } ... on RichTextBlock { value } ... on StreamFieldInterface { blockType } } } fragment BlogPageOuterView on BlogPage { id seoTitle slug thumb { ...DefaultImageView } title } fragment DefaultImageView on TFImage { height id rendition(width: 1200, height: 630, format: \"jpeg\", jpegquality: 85) { height id url width } srcSet(sizes: [768, 1080], format: \"webp\") url width } query BlogLiveView($slug: String) { page(slug: $slug) { ...BlogPageInnerView ...BlogPageOuterView } }"
}
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default class WTClient {
/**
* List all gallery image
*/
async listPictures(offset?: number, limit?: number) {
async listPictures(offset?: number, limit?: number, order?: string) {
return offset && limit
? execute(this.config, GalleryPaginatedListViewDocument, {
offset,
Expand All @@ -63,7 +63,7 @@ export default class WTClient {
/**
* List all blog page
*/
async listBlogs(offset?: number, limit?: number) {
async listBlogs(offset?: number, limit?: number, order?: string) {
return offset && limit
? execute(this.config, BlogPaginatedListViewDocument, {
offset,
Expand Down

0 comments on commit cff1c6c

Please sign in to comment.