File tree Expand file tree Collapse file tree 4 files changed +101
-0
lines changed Expand file tree Collapse file tree 4 files changed +101
-0
lines changed Original file line number Diff line number Diff line change 1+ build
2+ composer.lock
3+ vendor
4+ coverage
5+ .idea
6+ .php_cs.cache
Original file line number Diff line number Diff line change 1+ php :
2+ preset : laravel
3+ disabled :
4+ - unused_use
5+ finder :
6+ not-name :
7+ - index.php
8+ - server.php
9+ js :
10+ finder :
11+ not-name :
12+ - webpack.mix.js
13+ css : false
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " preprio/laravel-graphql-sdk" ,
3+ "description" : " Prepr GraphQL wrapper for Laravel" ,
4+ "keywords" : [" laravel" , " prepr" ],
5+ "license" : " MIT" ,
6+ "authors" : [
7+ {
8+ "name" : " Prepr" ,
9+ "email" : " support@prepr.io"
10+ }
11+ ],
12+ "minimum-stability" : " dev" ,
13+ "require" : {
14+
15+ },
16+ "autoload" : {
17+ "psr-4" : {
18+ "Preprio\\ " : " src/"
19+ }
20+ },
21+ "extra" : {
22+ "laravel" : {
23+ "providers" : [
24+ " Preprio\\ PreprServiceProvider"
25+ ]
26+ }
27+ }
28+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Preprio ;
4+
5+ use Illuminate \Support \Facades \Http ;
6+ use Illuminate \Support \ServiceProvider ;
7+
8+ class PreprServiceProvider extends ServiceProvider
9+ {
10+ /**
11+ * Bootstrap the application services.
12+ */
13+ public function boot ()
14+ {
15+ Http::macro ('prepr ' , function ($ data ) {
16+
17+ $ headers = [];
18+
19+ if (data_get ($ data ,'headers ' )) {
20+ $ headers = data_get ($ data ,'headers ' );
21+ }
22+
23+ if (\Request ()->hasHeader ('x-real-ip ' )) {
24+ data_set ($ headers , 'Prepr-Client-IP ' , \Request ()->header ('x-real-ip ' ));
25+ }
26+
27+ $ json = [
28+ 'query ' => null ,
29+ 'variables ' => []
30+ ];
31+
32+ if (data_get ($ data ,'query ' )) {
33+ $ json ['query ' ] = file_get_contents (app_path ('Queries/ ' . data_get ($ data ,'query ' ) . '.graphql ' ));
34+ } elseif (data_get ($ data ,'raw-query ' )) {
35+ $ json ['query ' ] = data_get ($ data ,'raw-query ' );
36+ }
37+
38+ if (data_get ($ data ,'variables ' )) {
39+ $ json ['variables ' ] = data_get ($ data ,'variables ' );
40+ }
41+
42+ return Http::acceptJson ()->withHeaders ($ headers )->post (config ('services.prepr.endpoint ' ), $ json );
43+
44+ });
45+ }
46+
47+ /**
48+ * Register the application services.
49+ */
50+ public function register ()
51+ {
52+
53+ }
54+ }
You can’t perform that action at this time.
0 commit comments