4
4
5
5
class ResolverStartupStartup extends Resolver
6
6
{
7
+ public function index ()
8
+ {
9
+ if (is_plugin_active ('d_vuefront/plugin.php ' )) {
10
+ if (! empty ($ _GET ['cors ' ])) {
11
+ if (! empty ($ _SERVER ['HTTP_ORIGIN ' ])) {
12
+ header ('Access-Control-Allow-Origin: ' . $ _SERVER ['HTTP_ORIGIN ' ]);
13
+ } else {
14
+ header ('Access-Control-Allow-Origin: * ' );
15
+ }
16
+ header ('Access-Control-Allow-Methods: POST, OPTIONS ' );
17
+ header ('Access-Control-Allow-Credentials: true ' );
18
+ header ('Access-Control-Allow-Headers: DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Token,token,Cookie,cookie,content-type ' );
19
+ }
7
20
8
- public function index () {
9
-
10
- if ( ! empty ( $ _GET ['cors ' ] ) ) {
11
- if ( ! empty ( $ _SERVER ['HTTP_ORIGIN ' ] ) ) {
12
- header ( 'Access-Control-Allow-Origin: ' . $ _SERVER ['HTTP_ORIGIN ' ] );
13
- } else {
14
- header ( 'Access-Control-Allow-Origin: * ' );
15
- }
16
- header ( 'Access-Control-Allow-Methods: POST, OPTIONS ' );
17
- header ( 'Access-Control-Allow-Credentials: true ' );
18
- header ( 'Access-Control-Allow-Headers: DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Token,token,Cookie,cookie,content-type ' );
19
- }
20
-
21
- $ this ->load ->model ('startup/startup ' );
21
+ $ this ->load ->model ('startup/startup ' );
22
22
23
- try {
24
- $ resolvers = $ this ->model_startup_startup ->getResolvers ();
25
- $ schema = BuildSchema::build (file_get_contents (DIR_PLUGIN .'schema.graphql ' ));
26
- $ rawInput = file_get_contents ('php://input ' );
27
- $ input = json_decode ($ rawInput , true );
28
- $ query = $ input ['query ' ];
23
+ try {
24
+ $ resolvers = $ this ->model_startup_startup ->getResolvers ();
25
+ $ schema = BuildSchema::build (file_get_contents (DIR_PLUGIN .'schema.graphql ' ));
26
+ $ rawInput = file_get_contents ('php://input ' );
27
+ $ input = json_decode ($ rawInput , true );
28
+ $ query = $ input ['query ' ];
29
29
30
- $ variableValues = isset ($ input ['variables ' ]) ? $ input ['variables ' ] : null ;
31
- $ result = GraphQL::executeQuery ($ schema , $ query , $ resolvers , null , $ variableValues );
32
- } catch (\Exception $ e ) {
33
- $ result = [
30
+ $ variableValues = isset ($ input ['variables ' ]) ? $ input ['variables ' ] : null ;
31
+ $ result = GraphQL::executeQuery ($ schema , $ query , $ resolvers , null , $ variableValues );
32
+ } catch (\Exception $ e ) {
33
+ $ result = [
34
34
'error ' => [
35
35
'message ' => $ e ->getMessage ()
36
36
]
37
37
];
38
- }
38
+ }
39
39
40
- echo json_encode ($ result );
40
+ echo json_encode ($ result );
41
+ }
41
42
}
42
- }
43
+ }
0 commit comments