Skip to content

Commit

Permalink
apply some edits to migration token
Browse files Browse the repository at this point in the history
  • Loading branch information
deva7mad committed May 10, 2023
1 parent caed496 commit b08948f
Show file tree
Hide file tree
Showing 23 changed files with 4,079 additions and 10 deletions.
157 changes: 157 additions & 0 deletions _lighthouse_ide_helper.php
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;
}
}
}
16 changes: 16 additions & 0 deletions app/GraphQL/Mutations/Post/CreatePostMutation.php
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');
}

}
39 changes: 39 additions & 0 deletions app/GraphQL/Queries/Comment/CommentQuery.php
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']);
}
}
42 changes: 42 additions & 0 deletions app/GraphQL/Queries/Comment/CommentsQuery.php
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();
}
}
39 changes: 39 additions & 0 deletions app/GraphQL/Queries/Post/PostQuery.php
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']);
}
}
32 changes: 32 additions & 0 deletions app/GraphQL/Queries/Post/PostsQuery.php
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();
}
}
30 changes: 30 additions & 0 deletions app/GraphQL/Types/CommentType.php
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'
],
];
}
}
Loading

0 comments on commit b08948f

Please sign in to comment.