-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #413 from safrpa/schema-validation-improvements
check if container contains given types, schema types unique
- Loading branch information
Showing
13 changed files
with
183 additions
and
12 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
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,10 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace Graphpinator\Typesystem\Exception; | ||
|
||
final class DirectiveNamesNotUnique extends TypeError | ||
{ | ||
public const MESSAGE = 'Directive names are not unique.'; | ||
} |
10 changes: 10 additions & 0 deletions
10
src/Typesystem/Exception/RootOperationTypesMustBeWithinContainer.php
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,10 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace Graphpinator\Typesystem\Exception; | ||
|
||
final class RootOperationTypesMustBeWithinContainer extends TypeError | ||
{ | ||
public const MESSAGE = 'Root operation types must be within container.'; | ||
} |
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,10 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace Graphpinator\Typesystem\Exception; | ||
|
||
final class TypeNamesNotUnique extends TypeError | ||
{ | ||
public const MESSAGE = 'Type names are not unique.'; | ||
} |
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
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
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
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
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
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
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
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,77 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace Graphpinator\Tests\Feature; | ||
|
||
use Graphpinator\SimpleContainer; | ||
use Graphpinator\Typesystem\Container; | ||
use Graphpinator\Typesystem\Exception\TypeNamesNotUnique; | ||
use Graphpinator\Typesystem\Field\ResolvableField; | ||
use Graphpinator\Typesystem\Field\ResolvableFieldSet; | ||
use Graphpinator\Typesystem\Type; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
final class TypeNamesNotUniqueTest extends TestCase | ||
{ | ||
public function testAllSame() : void | ||
{ | ||
$this->expectException(TypeNamesNotUnique::class); | ||
$this->expectExceptionMessage(TypeNamesNotUnique::MESSAGE); | ||
|
||
new SimpleContainer($this->getTypes(), []); | ||
} | ||
|
||
/** | ||
* @return array<Type> | ||
*/ | ||
private function getTypes() : array | ||
{ | ||
$types = []; | ||
$types[] = new class extends Type { | ||
protected const NAME = 'Query'; | ||
|
||
public function validateNonNullValue($rawValue) : bool | ||
{ | ||
return true; | ||
} | ||
|
||
protected function getFieldDefinition() : ResolvableFieldSet | ||
{ | ||
return new ResolvableFieldSet([ | ||
new ResolvableField( | ||
'field', | ||
Container::Int(), | ||
static function () : int { | ||
return 1; | ||
}, | ||
), | ||
]); | ||
} | ||
}; | ||
|
||
$types[] = new class extends Type { | ||
protected const NAME = 'Query'; | ||
|
||
public function validateNonNullValue($rawValue) : bool | ||
{ | ||
return true; | ||
} | ||
|
||
protected function getFieldDefinition() : ResolvableFieldSet | ||
{ | ||
return new ResolvableFieldSet([ | ||
new ResolvableField( | ||
'field', | ||
Container::Int(), | ||
static function () : int { | ||
return 1; | ||
}, | ||
), | ||
]); | ||
} | ||
}; | ||
|
||
return $types; | ||
} | ||
} |
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