|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Retour plugin for Craft CMS |
|
4
|
|
|
* |
|
5
|
|
|
* Retour allows you to intelligently redirect legacy URLs, so that you don't |
|
6
|
|
|
* lose SEO value when rebuilding & restructuring a website |
|
7
|
|
|
* |
|
8
|
|
|
* @link https://nystudio107.com/ |
|
|
|
|
|
|
9
|
|
|
* @copyright Copyright (c) 2019 nystudio107 |
|
|
|
|
|
|
10
|
|
|
*/ |
|
|
|
|
|
|
11
|
|
|
|
|
12
|
|
|
namespace nystudio107\retour\gql\queries; |
|
13
|
|
|
|
|
14
|
|
|
use craft\gql\base\Query; |
|
15
|
|
|
use GraphQL\Type\Definition\Type; |
|
16
|
|
|
use nystudio107\retour\gql\arguments\RetourArguments; |
|
17
|
|
|
|
|
18
|
|
|
use nystudio107\retour\gql\interfaces\RetourInterface; |
|
19
|
|
|
use nystudio107\retour\gql\resolvers\RetourResolver; |
|
20
|
|
|
use nystudio107\retour\helpers\Gql as GqlHelper; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Class RetourQuery |
|
24
|
|
|
* |
|
25
|
|
|
* @author nystudio107 |
|
|
|
|
|
|
26
|
|
|
* @package Retour |
|
|
|
|
|
|
27
|
|
|
* @since 3.1.26 |
|
|
|
|
|
|
28
|
|
|
*/ |
|
|
|
|
|
|
29
|
|
|
class RetourQuery extends Query |
|
30
|
|
|
{ |
|
31
|
|
|
/** |
|
|
|
|
|
|
32
|
|
|
* @inheritdoc |
|
33
|
|
|
*/ |
|
|
|
|
|
|
34
|
|
|
public static function getQueries($checkToken = true): array |
|
35
|
|
|
{ |
|
36
|
|
|
if ($checkToken && !GqlHelper::canQueryRetour()) { |
|
37
|
|
|
return []; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
return [ |
|
41
|
|
|
'retour' => [ |
|
42
|
|
|
'type' => RetourInterface::getType(), |
|
43
|
|
|
'args' => RetourArguments::getArguments(), |
|
44
|
|
|
'resolve' => RetourResolver::class . '::resolve', |
|
45
|
|
|
'description' => 'This query is used to query for Retour redirects.', |
|
46
|
|
|
'deprecationReason' => 'This query is deprecated and will be removed in the future. You should use `retourResolveRedirect` instead.', |
|
47
|
|
|
], |
|
48
|
|
|
'retourResolveRedirect' => [ |
|
49
|
|
|
'type' => RetourInterface::getType(), |
|
50
|
|
|
'args' => RetourArguments::getArguments(), |
|
51
|
|
|
'resolve' => RetourResolver::class . '::resolve', |
|
52
|
|
|
'description' => 'This query is used to query for Retour redirects.', |
|
53
|
|
|
], |
|
54
|
|
|
'retourRedirects' => [ |
|
55
|
|
|
'type' => Type::listOf(RetourInterface::getType()), |
|
56
|
|
|
'args' => [ |
|
57
|
|
|
'site' => [ |
|
58
|
|
|
'name' => 'site', |
|
59
|
|
|
'type' => Type::string(), |
|
60
|
|
|
'description' => 'The site handle to list all redirects for.', |
|
61
|
|
|
], |
|
62
|
|
|
'siteId' => [ |
|
63
|
|
|
'name' => 'siteId', |
|
64
|
|
|
'type' => Type::int(), |
|
65
|
|
|
'description' => 'The siteId to list all redirects for.', |
|
66
|
|
|
], |
|
67
|
|
|
], |
|
68
|
|
|
'resolve' => RetourResolver::class . '::resolveAll', |
|
69
|
|
|
'description' => 'This query is used to query for all Retour redirects for a site.', |
|
70
|
|
|
], |
|
71
|
|
|
]; |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|