Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored for PHP 8 #255

Open
wants to merge 40 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
475b40f
Update composer dependencies
Matys333 Oct 12, 2023
64a8139
Code update to PHP 8
Matys333 Oct 12, 2023
310a9ae
Add datetime as string to allowed scalar type names
Matys333 Oct 16, 2023
d5ea799
Add string or array to allowed scalar type names
Matys333 Oct 16, 2023
c7a0caa
Fix maxScore check if it is not defined
Matys333 Oct 17, 2023
70922fb
Fix collecting and checking types if type is null
Matys333 Oct 17, 2023
f6122ed
Fix getting item types
Matys333 Oct 17, 2023
43dff53
Fix MaxComplexityQueryVisitor if maxScore on null
Matys333 Oct 17, 2023
27533c5
Fix parent calls for types
Matys333 Oct 18, 2023
3da9e7f
Fix resolve for InputValueType, fix params error for NonNullType, Arg…
Matys333 Oct 18, 2023
aee2238
(Hot)Fix __DirectiveLocation in getScalarType
Matys333 Oct 18, 2023
4ebc971
Add more type checks, fix empty config check for types
Matys333 Oct 23, 2023
6221eb1
Fix errors with wrong types
Matys333 Oct 23, 2023
9390db1
Fix types
Matys333 Oct 23, 2023
e70ef39
Fix types
Matys333 Oct 23, 2023
9aa1362
Fix configCache in object and configs for parent constructor calls
Matys333 Oct 23, 2023
b88bfc4
Fix AutoNameTrait, change getName for types return value to be nullable
Matys333 Oct 23, 2023
abf4cac
Fix types, update traits typing
Matys333 Oct 23, 2023
6ced55b
Fix getType typing
Matys333 Oct 23, 2023
772e5b1
Fix alias if null, process code cleanup
Matys333 Oct 23, 2023
ff528e5
Fix processor typing
Matys333 Oct 23, 2023
9034c52
Update type checks, fix non null type constructor
Matys333 Oct 24, 2023
c0b8973
Fix null interfaces
Matys333 Oct 24, 2023
94d2e1f
Fix scalar check, update type validation rule
Matys333 Oct 24, 2023
f57b5d9
Update return types
Matys333 Oct 24, 2023
2631faa
Remove resolved hotfix, fix getField return type
Matys333 Oct 24, 2023
5e7cbcf
Fix Argument's value ValueInterface
Matys333 Nov 20, 2023
04a9b06
Add fallback for missing scalar types
Matys333 Nov 21, 2023
6fa1f83
Fix resolve functions return types
Matys333 Nov 21, 2023
01c135c
Fix return types
Matys333 Feb 12, 2024
5151278
Use class_exists to check for class existence
bartv2 Jan 23, 2024
e3c79d3
Use AbstractInputObjectType in typing
bartv2 Jan 23, 2024
62a20d0
Use DateTimeType for DateType implementation
bartv2 Mar 1, 2024
d1c9b09
Merge pull request #1 from bartv2/fix-type-factory
Matys333 May 29, 2024
b47d16d
Merge pull request #2 from bartv2/AbstractInputObjectType
Matys333 May 29, 2024
f0144ba
Merge pull request #3 from bartv2/DateType
Matys333 May 29, 2024
3037a3f
Update return types
Matys333 Aug 30, 2024
0c40309
Merge remote-tracking branch 'origin/master'
Matys333 Aug 30, 2024
634493e
Fix $config declaration
Matys333 Aug 30, 2024
728119e
Update ErrorContainerTrait - fix outputting same error messages if th…
Matys333 Oct 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ vendor/
data/schema.graphql
composer.lock
.idea
docker-compose.yml
Dockerfile
docker/
.env.local
14 changes: 9 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "youshido/graphql",
"description": "Pure PHP GraphQL",
"description": "Pure PHP 8.1+ GraphQL",
"license": "MIT",
"authors": [
{
Expand All @@ -10,15 +10,19 @@
{
"name": "Portey Vasil",
"email": "[email protected]"
},
{
"name": "Tom Atom",
"email": "[email protected]"
}
],
"require": {
"php": ">=5.5",
"php": ">=8.1",
"ext-mbstring": "*",
"symfony/property-access": "^2.8 || ^3.4 || ^4.4"
"symfony/property-access": "6.*"
},
"require-dev": {
"phpunit/phpunit": "^4.8"
"phpunit/phpunit": "10.*"
},
"autoload": {
"psr-4": {
Expand All @@ -30,4 +34,4 @@
"Youshido\\Tests\\": "tests"
}
}
}
}
5 changes: 3 additions & 2 deletions examples/02_blog/Schema/BannerType.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,22 @@

namespace Examples\Blog\Schema;

use Youshido\GraphQL\Config\Object\ObjectTypeConfig;
use Youshido\GraphQL\Type\NonNullType;
use Youshido\GraphQL\Type\Object\AbstractObjectType;
use Youshido\GraphQL\Type\Scalar\StringType;

class BannerType extends AbstractObjectType
{
public function build($config)
public function build(ObjectTypeConfig $config)
{
$config
->addField('title', new NonNullType(new StringType()))
->addField('summary', new StringType())
->addField('imageLink', new StringType());
}

public function getInterfaces()
public function getInterfaces(): array
{
return [new ContentBlockInterface()];
}
Expand Down
3 changes: 2 additions & 1 deletion examples/02_blog/Schema/ContentBlockInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
namespace Examples\Blog\Schema;


use Youshido\GraphQL\Config\Object\InterfaceTypeConfig;
use Youshido\GraphQL\Type\InterfaceType\AbstractInterfaceType;
use Youshido\GraphQL\Type\NonNullType;
use Youshido\GraphQL\Type\Scalar\StringType;

class ContentBlockInterface extends AbstractInterfaceType
{

public function build($config)
public function build(InterfaceTypeConfig $config)
{
$config->addField('title', new NonNullType(new StringType()));
$config->addField('summary', new StringType());
Expand Down
5 changes: 3 additions & 2 deletions examples/02_blog/Schema/ContentBlockUnion.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@
namespace Examples\Blog\Schema;


use Youshido\GraphQL\Type\AbstractType;
use Youshido\GraphQL\Type\Union\AbstractUnionType;

class ContentBlockUnion extends AbstractUnionType
{
public function getTypes()
public function getTypes(): array
{
return [new PostType(), new BannerType()];
}

public function resolveType($object)
public function resolveType(object $object): ?AbstractType
{
return empty($object['id']) ? null : (strpos($object['id'], 'post') !== false ? new PostType() : new BannerType());
}
Expand Down
2 changes: 1 addition & 1 deletion examples/02_blog/Schema/LikePostField.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function getType()
return new PostType();
}

public function build(FieldConfig $config)
public function build(FieldConfig $config): void
{
$config->addArgument('id', new NonNullType(new IntType()));
}
Expand Down
2 changes: 1 addition & 1 deletion examples/02_blog/Schema/PostStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class PostStatus extends AbstractEnumType
{
public function getValues()
public function getValues(): array
{
return [
[
Expand Down
7 changes: 4 additions & 3 deletions examples/02_blog/Schema/PostType.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

namespace Examples\Blog\Schema;

use Youshido\GraphQL\Config\Object\ObjectTypeConfig;
use Youshido\GraphQL\Type\NonNullType;
use Youshido\GraphQL\Type\Object\AbstractObjectType;
use Youshido\GraphQL\Type\Scalar\BooleanType;
Expand All @@ -14,10 +15,10 @@
class PostType extends AbstractObjectType
{
/**
* @param \Youshido\GraphQL\Config\Object\ObjectTypeConfig $config
* @param ObjectTypeConfig $config
* @throws \Youshido\GraphQL\Exception\ConfigurationException
*/
public function build($config)
public function build(ObjectTypeConfig $config)
{
$config
->addField('oldTitle', [
Expand Down Expand Up @@ -49,7 +50,7 @@ public function getOne($id)
return DataProvider::getPost($id);
}

public function getInterfaces()
public function getInterfaces(): array
{
return [new ContentBlockInterface()];
}
Expand Down
7 changes: 4 additions & 3 deletions examples/03_relay_star_wars/Schema/FactionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
namespace Examples\StarWars;


use Youshido\GraphQL\Config\Object\ObjectTypeConfig;
use Youshido\GraphQL\Relay\Connection\ArrayConnection;
use Youshido\GraphQL\Relay\Connection\Connection;
use Youshido\GraphQL\Relay\Field\GlobalIdField;
Expand All @@ -22,7 +23,7 @@ class FactionType extends AbstractObjectType

const TYPE_KEY = 'faction';

public function build($config)
public function build(ObjectTypeConfig $config)
{
$config
->addField(new GlobalIdField(self::TYPE_KEY))
Expand All @@ -49,7 +50,7 @@ public function build($config)

}

public function getDescription()
public function getDescription(): string
{
return 'A faction in the Star Wars saga';
}
Expand All @@ -59,7 +60,7 @@ public function getOne($id)
return TestDataProvider::getFaction($id);
}

public function getInterfaces()
public function getInterfaces(): array
{
return [new NodeInterfaceType()];
}
Expand Down
7 changes: 4 additions & 3 deletions examples/03_relay_star_wars/Schema/ShipType.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
namespace Examples\StarWars;


use Youshido\GraphQL\Config\Object\ObjectTypeConfig;
use Youshido\GraphQL\Relay\Field\GlobalIdField;
use Youshido\GraphQL\Relay\NodeInterfaceType;
use Youshido\GraphQL\Type\Object\AbstractObjectType;
Expand All @@ -18,7 +19,7 @@ class ShipType extends AbstractObjectType
{
const TYPE_KEY = 'ship';

public function build($config)
public function build(ObjectTypeConfig $config)
{
$config
->addField(new GlobalIdField(self::TYPE_KEY))
Expand All @@ -30,12 +31,12 @@ public function getOne($id)
return TestDataProvider::getShip($id);
}

public function getDescription()
public function getDescription(): string
{
return 'A ship in the Star Wars saga';
}

public function getInterfaces()
public function getInterfaces(): array
{
return [new NodeInterfaceType()];
}
Expand Down
22 changes: 11 additions & 11 deletions examples/03_relay_star_wars/Schema/StarWarsRelaySchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Examples\StarWars;

use Youshido\GraphQL\Config\Schema\SchemaConfig;
use Youshido\GraphQL\Exception\ConfigurationException;
use Youshido\GraphQL\Field\InputField;
use Youshido\GraphQl\Relay\Connection\ArrayConnection;
use Youshido\GraphQL\Relay\Connection\Connection;
Expand All @@ -16,20 +17,19 @@

class StarWarsRelaySchema extends AbstractSchema
{
public function build(SchemaConfig $config)
/**
* @throws ConfigurationException
*/
public function build(SchemaConfig $config): void
{
$fetcher = new CallableFetcher(
function ($type, $id) {
switch ($type) {
case FactionType::TYPE_KEY:
return TestDataProvider::getFaction($id);
return match ($type) {
FactionType::TYPE_KEY => TestDataProvider::getFaction($id),
ShipType::TYPE_KEY => TestDataProvider::getShip($id),
default => null,
};

case
ShipType::TYPE_KEY:
return TestDataProvider::getShip($id);
}

return null;
},
function ($object) {
return $object && array_key_exists('ships', $object) ? new FactionType() : new ShipType();
Expand Down Expand Up @@ -57,7 +57,7 @@ function ($object) {
'type' => new ListType(new StringType())
]
],
'resolve' => function ($value = null, $args, $info) {
'resolve' => function ($args, $info, $value = null) {
return TestDataProvider::getByNames($args['names']);
}
]);
Expand Down
3 changes: 2 additions & 1 deletion examples/04_bookstore/Schema/Type/AuthorType.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@

namespace Examples\BookStore\Schema\Type;

use Youshido\GraphQL\Config\Object\ObjectTypeConfig;
use Youshido\GraphQL\Type\NonNullType;
use Youshido\GraphQL\Type\Object\AbstractObjectType;
use Youshido\GraphQL\Type\Scalar\IdType;
use Youshido\GraphQL\Type\Scalar\StringType;

class AuthorType extends AbstractObjectType
{
public function build($config)
public function build(ObjectTypeConfig $config)
{
$config->addFields([
'id' => new NonNullType(new IdType()),
Expand Down
2 changes: 1 addition & 1 deletion examples/04_bookstore/Schema/Type/BookType.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

class BookType extends AbstractObjectType
{
public function build($config)
public function build(ObjectTypeConfig $config)
{
$config->addFields([
'id' => new IdType(),
Expand Down
3 changes: 2 additions & 1 deletion examples/04_bookstore/Schema/Type/CategoryType.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
namespace Examples\BookStore\Schema\Type;

use Examples\BookStore\Schema\Field\CategoriesField;
use Youshido\GraphQL\Config\Object\ObjectTypeConfig;
use Youshido\GraphQL\Type\ListType\ListType;
use Youshido\GraphQL\Type\Object\AbstractObjectType;
use Youshido\GraphQL\Type\Scalar\IdType;
use Youshido\GraphQL\Type\Scalar\StringType;

class CategoryType extends AbstractObjectType
{
public function build($config)
public function build(ObjectTypeConfig $config)
{
$config->addFields([
'id' => new IdType(),
Expand Down
Loading