-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
4,079 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
<?php | ||
# File generated by "php artisan lighthouse:ide-helper". | ||
# Do not edit this file directly. | ||
# This file should be ignored by git as it can be autogenerated. | ||
|
||
|
||
namespace Illuminate\Foundation\Testing { | ||
class TestResponse | ||
{ | ||
/** | ||
* Asserts that the response contains an error from a given category. | ||
* | ||
* @param string $category the name of the expected error category | ||
* | ||
* @return $this | ||
*/ | ||
public function assertGraphQLErrorCategory(string $category): self | ||
{ | ||
return $this; | ||
} | ||
|
||
/** | ||
* Assert that the returned result contains exactly the given validation keys. | ||
* | ||
* @param array<string> $keys the validation keys the result should have | ||
* | ||
* @return $this | ||
*/ | ||
public function assertGraphQLValidationKeys(array $keys): self | ||
{ | ||
return $this; | ||
} | ||
|
||
/** | ||
* Assert that a given validation error is present in the response. | ||
* | ||
* @param string $key the validation key that should be present | ||
* @param string $message the expected validation message | ||
* | ||
* @return $this | ||
*/ | ||
public function assertGraphQLValidationError(string $key, string $message): self | ||
{ | ||
return $this; | ||
} | ||
|
||
/** | ||
* Assert that no validation errors are present in the response. | ||
* | ||
* @return $this | ||
*/ | ||
public function assertGraphQLValidationPasses(): self | ||
{ | ||
return $this; | ||
} | ||
} | ||
} | ||
|
||
namespace Illuminate\Testing { | ||
class TestResponse | ||
{ | ||
/** | ||
* Assert the response contains an error with a matching message. | ||
* | ||
* @param \Throwable $error the expected error | ||
* | ||
* @return $this | ||
*/ | ||
public function assertGraphQLError(\Throwable $error): self | ||
{ | ||
return $this; | ||
} | ||
|
||
/** | ||
* Assert the response contains an error with the given message. | ||
* | ||
* @param string $message the expected error message | ||
* | ||
* @return $this | ||
*/ | ||
public function assertGraphQLErrorMessage(string $message): self | ||
{ | ||
return $this; | ||
} | ||
|
||
/** | ||
* Assert the response contains an error with the given debug message. | ||
* | ||
* Requires the config `lighthouse.debug` to include the option \GraphQL\Error\DebugFlag::INCLUDE_DEBUG_MESSAGE. | ||
* | ||
* @param string $message the expected debug message | ||
* | ||
* @return $this | ||
*/ | ||
public function assertGraphQLDebugMessage(string $message): self | ||
{ | ||
return $this; | ||
} | ||
|
||
/** | ||
* Assert the response contains no errors. | ||
* | ||
* @return $this | ||
*/ | ||
public function assertGraphQLErrorFree(): self | ||
{ | ||
return $this; | ||
} | ||
|
||
/** | ||
* Assert the response contains an error from the given category. | ||
* | ||
* @param string $category the name of the expected error category | ||
* | ||
* @return $this | ||
*/ | ||
public function assertGraphQLErrorCategory(string $category): self | ||
{ | ||
return $this; | ||
} | ||
|
||
/** | ||
* Assert the returned result contains exactly the given validation keys. | ||
* | ||
* @param array<string> $keys the validation keys the result should have | ||
* | ||
* @return $this | ||
*/ | ||
public function assertGraphQLValidationKeys(array $keys): self | ||
{ | ||
return $this; | ||
} | ||
|
||
/** | ||
* Assert a given validation error is present in the response. | ||
* | ||
* @param string $key the validation key that should be present | ||
* @param string $message the expected validation message | ||
* | ||
* @return $this | ||
*/ | ||
public function assertGraphQLValidationError(string $key, string $message): self | ||
{ | ||
return $this; | ||
} | ||
|
||
/** | ||
* Assert no validation errors are present in the response. | ||
* | ||
* @return $this | ||
*/ | ||
public function assertGraphQLValidationPasses(): self | ||
{ | ||
return $this; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace App\GraphQL\Mutations\Post; | ||
|
||
use Rebing\GraphQL\Support\Mutation; | ||
use Rebing\GraphQL\Support\Facades\GraphQL; | ||
use GraphQL\Type\Definition\Type as GraphQLType; | ||
|
||
class CreatePostMutation extends Mutation | ||
{ | ||
public function type(): GraphQLType | ||
{ | ||
return GraphQL::type('Post'); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace App\GraphQL\Queries\Comment; | ||
|
||
use App\Models\Comment; | ||
use GraphQL\Type\Definition\Type; | ||
use Rebing\GraphQL\Support\Query; | ||
use Rebing\GraphQL\Support\Facades\GraphQL; | ||
|
||
class CommentQuery extends Query | ||
{ | ||
protected $attributes = [ | ||
'name' => 'comment', | ||
]; | ||
|
||
/** | ||
* @return Type | ||
*/ | ||
public function type(): Type | ||
{ | ||
return GraphQL::type('Comment'); | ||
} | ||
|
||
public function args(): array | ||
{ | ||
return [ | ||
'id' => [ | ||
'name' => 'id', | ||
'type' => Type::int(), | ||
'rules' => ['required'] | ||
] | ||
]; | ||
} | ||
|
||
public function resolve($root, $args) | ||
{ | ||
return Comment::findOrFail($args['id']); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
namespace App\GraphQL\Queries\Comment; | ||
|
||
use App\Models\Comment; | ||
use GraphQL\Type\Definition\Type; | ||
use Rebing\GraphQL\Support\Query; | ||
use Rebing\GraphQL\Support\Facades\GraphQL; | ||
use Illuminate\Database\Eloquent\Collection; | ||
|
||
class CommentsQuery extends Query | ||
{ | ||
protected $attributes = [ | ||
'name' => 'comments', | ||
]; | ||
|
||
public function type(): Type | ||
{ | ||
return Type::listOf(GraphQL::type('Comment')); | ||
} | ||
|
||
public function args(): array | ||
{ | ||
return [ | ||
'id' => [ | ||
'name' => 'id', | ||
'type' => Type::int(), | ||
'rules' => ['required'] | ||
] | ||
]; | ||
} | ||
|
||
/** | ||
* @param $root | ||
* @param $args | ||
* @return Collection | ||
*/ | ||
public function resolve($root, $args): Collection | ||
{ | ||
return Comment::all(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace App\GraphQL\Queries\Post; | ||
|
||
use App\Models\Post; | ||
use Rebing\GraphQL\Support\Query; | ||
use GraphQL\Type\Definition\Type; | ||
use Rebing\GraphQL\Support\Facades\GraphQL; | ||
|
||
class PostQuery extends Query | ||
{ | ||
protected $attributes = [ | ||
'name' => 'post', | ||
]; | ||
|
||
/** | ||
* @return Type | ||
*/ | ||
public function type(): Type | ||
{ | ||
return GraphQL::type('Post'); | ||
} | ||
|
||
public function args(): array | ||
{ | ||
return [ | ||
'id' => [ | ||
'name' => 'id', | ||
'type' => Type::int(), | ||
'rules' => ['required'] | ||
] | ||
]; | ||
} | ||
|
||
public function resolve($root, $args) | ||
{ | ||
return Post::findOrFail($args['id']); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace App\GraphQL\Queries\Post; | ||
|
||
use App\Models\Post; | ||
use Rebing\GraphQL\Support\Query; | ||
use GraphQL\Type\Definition\Type; | ||
use Rebing\GraphQL\Support\Facades\GraphQL; | ||
use Illuminate\Database\Eloquent\Collection; | ||
|
||
|
||
class PostsQuery extends Query | ||
{ | ||
protected $attributes = [ | ||
'name' => 'posts', | ||
]; | ||
|
||
public function type(): Type | ||
{ | ||
return Type::listOf(GraphQL::type('Post')); | ||
} | ||
|
||
/** | ||
* @param $root | ||
* @param $args | ||
* @return Collection | ||
*/ | ||
public function resolve($root, $args): Collection | ||
{ | ||
return Post::all(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace App\GraphQL\Types; | ||
|
||
use App\Models\Comment; | ||
use GraphQL\Type\Definition\Type; | ||
use Rebing\GraphQL\Support\Type as GraphQLType; | ||
|
||
class CommentType extends GraphQLType | ||
{ | ||
protected $attributes = [ | ||
'name' => 'Comment', | ||
'description' => 'Collection of comments', | ||
'model' => Comment::class | ||
]; | ||
|
||
public function fields(): array | ||
{ | ||
return [ | ||
'id' => [ | ||
'type' => Type::nonNull(Type::int()), | ||
'description' => 'ID of comment' | ||
], | ||
'body' => [ | ||
'type' => Type::nonNull(Type::string()), | ||
'description' => 'Body of the comment' | ||
], | ||
]; | ||
} | ||
} |
Oops, something went wrong.