File tree Expand file tree Collapse file tree 3 files changed +41
-3
lines changed Expand file tree Collapse file tree 3 files changed +41
-3
lines changed Original file line number Diff line number Diff line change 1
- query SearchProducts ($search : String ) {
2
- products (first : 10 , query : $search , sortKey : BEST_SELLING ) {
1
+ query SearchProducts ($search : String ! , $limit : Int ! , $cursor_next : String ) {
2
+ products (
3
+ first : $limit
4
+ after : $cursor_next
5
+ query : $search
6
+ sortKey : BEST_SELLING
7
+ ) {
8
+ pageInfo {
9
+ hasNextPage
10
+ hasPreviousPage
11
+ startCursor
12
+ endCursor
13
+ }
3
14
edges {
4
15
node {
5
16
id
Original file line number Diff line number Diff line change @@ -86,6 +86,19 @@ public static function get_queries( ShopifyDataSource $data_source ): array {
86
86
'search ' => [
87
87
'type ' => 'ui:search_input ' ,
88
88
],
89
+ 'limit ' => [
90
+ 'default_value ' => 8 ,
91
+ 'name ' => 'Items per page ' ,
92
+ 'type ' => 'ui:pagination_per_page ' ,
93
+ ],
94
+ 'cursor_next ' => [
95
+ 'name ' => 'Next page cursor ' ,
96
+ 'type ' => 'ui:pagination_cursor_next ' ,
97
+ ],
98
+ 'cursor_previous ' => [
99
+ 'name ' => 'Previous page cursor ' ,
100
+ 'type ' => 'ui:pagination_cursor_previous ' ,
101
+ ],
89
102
],
90
103
'output_schema ' => [
91
104
'path ' => '$.data.products.edges[*] ' ,
@@ -113,6 +126,18 @@ public static function get_queries( ShopifyDataSource $data_source ): array {
113
126
],
114
127
],
115
128
],
129
+ 'pagination_schema ' => [
130
+ 'cursor_next ' => [
131
+ 'name ' => 'Next page cursor ' ,
132
+ 'path ' => '$.data.products.pageInfo.endCursor ' ,
133
+ 'type ' => 'string ' ,
134
+ ],
135
+ 'cursor_previous ' => [
136
+ 'name ' => 'Previous page cursor ' ,
137
+ 'path ' => '$.data.products.pageInfo.startCursor ' ,
138
+ 'type ' => 'string ' ,
139
+ ],
140
+ ],
116
141
'graphql_query ' => file_get_contents ( __DIR__ . '/Queries/SearchProducts.graphql ' ),
117
142
] ),
118
143
];
Original file line number Diff line number Diff line change @@ -291,11 +291,13 @@ private static function generate_http_query_config_schema(): array {
291
291
// items available in paginated results. This field must be defined
292
292
// in order present to enable pagination support of any type,
293
293
// including cursor-based pagination.
294
- 'total_items ' => Types::object ( [
294
+ 'total_items ' => Types::nullable (
295
+ Types::object ( [
295
296
'name ' => Types::nullable ( Types::string () ),
296
297
'path ' => Types::json_path (),
297
298
'type ' => Types::enum ( 'integer ' ),
298
299
] ),
300
+ ),
299
301
// This field provides a pagination cursor for the next page of
300
302
// paginated results, or a null value if there is no next page. This
301
303
// field must be defined in order to enable cursor-based pagination.
You can’t perform that action at this time.
0 commit comments