Skip to content

Commit 3ea15ac

Browse files
committed
start working on graphql part
1 parent df88d8d commit 3ea15ac

File tree

16 files changed

+897
-34
lines changed

16 files changed

+897
-34
lines changed

app/GraphQL/Mutations/Login.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace App\GraphQL\Mutations;
4+
5+
final class Login
6+
{
7+
/**
8+
* @param null $_
9+
* @param array{} $args
10+
*/
11+
public function __invoke($_, array $args)
12+
{
13+
// TODO implement the resolver
14+
}
15+
}

app/Models/Post.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,19 @@
44

55
use Illuminate\Database\Eloquent\Factories\HasFactory;
66
use Illuminate\Database\Eloquent\Model;
7+
use Illuminate\Database\Eloquent\Relations\BelongsTo;
78

89
class Post extends Model
910
{
1011
use HasFactory;
12+
13+
public function author(): BelongsTo
14+
{
15+
return $this->belongsTo(User::class, "author");
16+
}
17+
18+
public function category(): BelongsTo
19+
{
20+
return $this->belongsTo(Category::class, "category");
21+
}
1122
}

app/Models/User.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
// use Illuminate\Contracts\Auth\MustVerifyEmail;
66
use Illuminate\Database\Eloquent\Factories\HasFactory;
7+
use Illuminate\Database\Eloquent\Relations\HasMany;
78
use Illuminate\Foundation\Auth\User as Authenticatable;
89
use Illuminate\Notifications\Notifiable;
910
use Laravel\Sanctum\HasApiTokens;
@@ -43,4 +44,9 @@ class User extends Authenticatable
4344
'email_verified_at' => 'datetime',
4445
'password' => 'hashed',
4546
];
47+
48+
public function posts(): HasMany
49+
{
50+
return $this->hasMany(Post::class, "author");
51+
}
4652
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
3+
namespace App\Providers;
4+
5+
use Illuminate\Support\Facades\Gate;
6+
use Laravel\Telescope\IncomingEntry;
7+
use Laravel\Telescope\Telescope;
8+
use Laravel\Telescope\TelescopeApplicationServiceProvider;
9+
10+
class TelescopeServiceProvider extends TelescopeApplicationServiceProvider
11+
{
12+
/**
13+
* Register any application services.
14+
*/
15+
public function register(): void
16+
{
17+
// Telescope::night();
18+
19+
$this->hideSensitiveRequestDetails();
20+
21+
Telescope::filter(function (IncomingEntry $entry) {
22+
if ($this->app->environment('local')) {
23+
return true;
24+
}
25+
26+
return $entry->isReportableException() ||
27+
$entry->isFailedRequest() ||
28+
$entry->isFailedJob() ||
29+
$entry->isScheduledTask() ||
30+
$entry->hasMonitoredTag();
31+
});
32+
}
33+
34+
/**
35+
* Prevent sensitive request details from being logged by Telescope.
36+
*/
37+
protected function hideSensitiveRequestDetails(): void
38+
{
39+
if ($this->app->environment('local')) {
40+
return;
41+
}
42+
43+
Telescope::hideRequestParameters(['_token']);
44+
45+
Telescope::hideRequestHeaders([
46+
'cookie',
47+
'x-csrf-token',
48+
'x-xsrf-token',
49+
]);
50+
}
51+
52+
/**
53+
* Register the Telescope gate.
54+
*
55+
* This gate determines who can access Telescope in non-local environments.
56+
*/
57+
protected function gate(): void
58+
{
59+
Gate::define('viewTelescope', function ($user) {
60+
return in_array($user->email, [
61+
//
62+
]);
63+
});
64+
}
65+
}

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"guzzlehttp/guzzle": "^7.2",
1010
"laravel/framework": "^10.10",
1111
"laravel/sanctum": "^3.2",
12+
"laravel/telescope": "^4.15",
1213
"laravel/tinker": "^2.8",
1314
"mll-lab/laravel-graphiql": "^3.1",
1415
"nuwave/lighthouse": "^6.16"

composer.lock

Lines changed: 72 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/app.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@
168168
// App\Providers\BroadcastServiceProvider::class,
169169
App\Providers\EventServiceProvider::class,
170170
App\Providers\RouteServiceProvider::class,
171+
App\Providers\TelescopeServiceProvider::class,
171172
])->toArray(),
172173

173174
/*

config/auth.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@
4040
'driver' => 'session',
4141
'provider' => 'users',
4242
],
43+
'api' => [
44+
'driver' => 'sanctum',
45+
'provider' => 'users'
46+
]
4347
],
4448

4549
/*

0 commit comments

Comments
 (0)