44
55class ResolverStartupStartup extends Resolver
66{
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+ }
720
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 ' );
2222
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 ' ];
2929
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 = [
3434 'error ' => [
3535 'message ' => $ e ->getMessage ()
3636 ]
3737 ];
38- }
38+ }
3939
40- echo json_encode ($ result );
40+ echo json_encode ($ result );
41+ }
4142 }
42- }
43+ }
0 commit comments