Skip to content

Commit 79760f6

Browse files
committed
Added new api
1 parent eef86e6 commit 79760f6

File tree

8 files changed

+58
-2
lines changed

8 files changed

+58
-2
lines changed

mapping.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
"accountEditAddress": "common/account/editAddress",
1212
"accountRemoveAddress": "common/account/removeAddress",
1313

14+
"home": "common/home/get",
15+
1416
"uploadFile": "common/file/upload",
1517

1618
"countriesList": "common/country/getList",

resolver/blog/category.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ public function get($data) {
1212
$keyword = str_replace(get_site_url(), '', get_term_link((int)$category->ID));
1313
$keyword = trim($keyword, '/?');
1414
$keyword = trim($keyword, '/');
15-
1615
return array(
1716
'id' => $category->ID,
1817
'name' => $category->name,
@@ -21,6 +20,11 @@ public function get($data) {
2120
'image' => $thumb,
2221
'keyword' => $keyword,
2322
'imageLazy' => $thumbLazy,
23+
'meta' => array(
24+
'title' => $category->name,
25+
'description' => $category->description,
26+
'keyword' => ''
27+
),
2428
'url' => function($root, $args) {
2529
return $this->url(array(
2630
'parent' => $root,

resolver/blog/post.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ public function get($args)
3131
'keyword' => $keyword,
3232
'image' => $thumb,
3333
'imageLazy' => $thumbLazy,
34+
'meta' => array(
35+
'title' => $post->title,
36+
'description' => $post->shortDescription,
37+
'keyword' => ''
38+
),
3439
'prev' => function ($root, $args) {
3540
return $this->load->resolver('blog/post/prev', array(
3641
'parent' => $root,

resolver/common/home.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
class ResolverCommonHome extends Resolver
4+
{
5+
public function get() {
6+
return array(
7+
'meta' => array(
8+
'title' => get_option('blogname'),
9+
'description' => get_option('blogdescription'),
10+
'keyword' => ''
11+
)
12+
);
13+
}
14+
}

resolver/common/page.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@ public function get($args) {
1616
'name' => $page_info->title,
1717
'description' => $page_info->description,
1818
'sort_order' => (int)$page_info->sort_order,
19-
'keyword' => $keyword
19+
'keyword' => $keyword,
20+
'meta' => array(
21+
'title' => $page_info->title,
22+
'description' => $page_info->description,
23+
'keyword' => ''
24+
),
2025
);
2126
}
2227

resolver/store/category.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ public function get($args) {
2828
'parent_id' => (string) $category_info->parent,
2929
'image' => $thumb,
3030
'imageLazy' => $thumbLazy,
31+
'meta' => array(
32+
'title' => $category_info->name,
33+
'description' => $category_info->description,
34+
'keyword' => ''
35+
),
3136
'url' => function($root, $args) {
3237
return $this->url(array(
3338
'parent' => $root,

resolver/store/product.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ public function get($args) {
6464
'stock' => $product->stock_status === 'instock',
6565
'rating' => (float) $product->rating,
6666
'keyword' => $keyword,
67+
'meta' => array(
68+
'title' => $product->name,
69+
'description' => $product->short_description,
70+
'keyword' => ''
71+
),
6772
'images' => function($root, $args) {
6873
return $this->getImages(array(
6974
'parent' => $root,

schema.graphql

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ type Category {
3939
url(url: String): String
4040
categories(limit: Int = 3): [Category]
4141
keyword: String
42+
meta: Meta
4243
}
4344

4445
type categoryBlog {
@@ -51,6 +52,7 @@ type categoryBlog {
5152
url(url: String): String
5253
keyword: String
5354
categories(limit: Int = 3): [categoryBlog]
55+
meta: Meta
5456
}
5557

5658
type categoryBlogResult {
@@ -125,6 +127,7 @@ type Page {
125127
name: String
126128
description: String
127129
keyword: String
130+
meta: Meta
128131
sort_order: Int
129132
}
130133

@@ -159,6 +162,7 @@ type Post {
159162
datePublished: String
160163
next: Post
161164
prev: Post
165+
meta: Meta
162166
}
163167

164168
type PostResult {
@@ -211,6 +215,7 @@ type Product {
211215
options: [productOption]
212216
images(limit: Int = 3): [productImage]
213217
keyword: String
218+
meta: Meta
214219
}
215220

216221
type productAttribute {
@@ -332,6 +337,16 @@ type CheckoutLinkResult {
332337
link: String
333338
}
334339

340+
type Meta {
341+
title: String
342+
description: String
343+
keyword: String
344+
}
345+
346+
type HomeResult {
347+
meta: Meta
348+
}
349+
335350
type RootMutationType {
336351
uploadFile(file: Upload): FileResult
337352
accountLogin(email: String, password: String): Customer
@@ -357,6 +372,7 @@ type RootMutationType {
357372
}
358373

359374
type RootQueryType {
375+
home: HomeResult
360376
zone(id: Int): Zone
361377
zonesList(page: Int = 1, size: Int = 10, search: String, country_id: String, sort: String = "name", order: String = "ASC"): ZonesResult
362378
country(id: Int): Country

0 commit comments

Comments
 (0)