Skip to content

Commit

Permalink
Merge pull request #1078 from crissi/build_a_valid_schema
Browse files Browse the repository at this point in the history
  • Loading branch information
mfn authored Aug 6, 2023
2 parents e02f4d5 + 2f95444 commit 106d060
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ CHANGELOG

[Next release](https://github.com/rebing/graphql-laravel/compare/9.0.0...master)
--------------
## Fixed
- fix schema validation - resolve not allowed in input fields [\#1078 / crissi](https://github.com/rebing/graphql-laravel/pull/1078)

2023-06-25, 9.0.0
-----------------
Expand Down
2 changes: 1 addition & 1 deletion phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ parameters:
path: src/GraphQL.php

-
message: "#^Parameter \\#1 \\$config of class GraphQL\\\\Type\\\\Schema constructor expects array\\{query\\?\\: GraphQL\\\\Type\\\\Definition\\\\ObjectType\\|null, mutation\\?\\: GraphQL\\\\Type\\\\Definition\\\\ObjectType\\|null, subscription\\?\\: GraphQL\\\\Type\\\\Definition\\\\ObjectType\\|null, types\\?\\: \\(callable\\(\\)\\: iterable\\<GraphQL\\\\Type\\\\Definition\\\\NamedType&GraphQL\\\\Type\\\\Definition\\\\Type\\>\\)\\|iterable\\<GraphQL\\\\Type\\\\Definition\\\\NamedType&GraphQL\\\\Type\\\\Definition\\\\Type\\>\\|null, directives\\?\\: array\\<GraphQL\\\\Type\\\\Definition\\\\Directive\\>\\|null, typeLoader\\?\\: \\(callable\\(string\\)\\: \\(\\(GraphQL\\\\Type\\\\Definition\\\\NamedType&GraphQL\\\\Type\\\\Definition\\\\Type\\)\\|null\\)\\)\\|null, assumeValid\\?\\: bool\\|null, astNode\\?\\: GraphQL\\\\Language\\\\AST\\\\SchemaDefinitionNode\\|null, \\.\\.\\.\\}\\|GraphQL\\\\Type\\\\SchemaConfig, array\\{query\\: GraphQL\\\\Type\\\\Definition\\\\Type, mutation\\: GraphQL\\\\Type\\\\Definition\\\\Type\\|null, subscription\\: GraphQL\\\\Type\\\\Definition\\\\Type\\|null, directives\\: array\\<int\\|string, mixed\\>, types\\: Closure\\(\\)\\: list\\<GraphQL\\\\Type\\\\Definition\\\\Type\\>, typeLoader\\: Closure\\(mixed\\)\\: \\(GraphQL\\\\Type\\\\Definition\\\\Type\\|null\\)\\} given\\.$#"
message: "#^Parameter \\#1 \\$config of class GraphQL\\\\Type\\\\Schema constructor expects array\\{query\\?\\: \\(callable\\(\\)\\: GraphQL\\\\Type\\\\Definition\\\\ObjectType\\)\\|GraphQL\\\\Type\\\\Definition\\\\ObjectType\\|null, mutation\\?\\: \\(callable\\(\\)\\: GraphQL\\\\Type\\\\Definition\\\\ObjectType\\)\\|GraphQL\\\\Type\\\\Definition\\\\ObjectType\\|null, subscription\\?\\: \\(callable\\(\\)\\: GraphQL\\\\Type\\\\Definition\\\\ObjectType\\)\\|GraphQL\\\\Type\\\\Definition\\\\ObjectType\\|null, types\\?\\: \\(callable\\(\\)\\: iterable\\<GraphQL\\\\Type\\\\Definition\\\\NamedType&GraphQL\\\\Type\\\\Definition\\\\Type\\>\\)\\|iterable\\<GraphQL\\\\Type\\\\Definition\\\\NamedType&GraphQL\\\\Type\\\\Definition\\\\Type\\>\\|null, directives\\?\\: array\\<GraphQL\\\\Type\\\\Definition\\\\Directive\\>\\|null, typeLoader\\?\\: \\(callable\\(string\\)\\: \\(\\(GraphQL\\\\Type\\\\Definition\\\\NamedType&GraphQL\\\\Type\\\\Definition\\\\Type\\)\\|null\\)\\)\\|null, assumeValid\\?\\: bool\\|null, astNode\\?\\: GraphQL\\\\Language\\\\AST\\\\SchemaDefinitionNode\\|null, \\.\\.\\.\\}\\|GraphQL\\\\Type\\\\SchemaConfig, array\\{query\\: GraphQL\\\\Type\\\\Definition\\\\Type, mutation\\: GraphQL\\\\Type\\\\Definition\\\\Type\\|null, subscription\\: GraphQL\\\\Type\\\\Definition\\\\Type\\|null, directives\\: array\\<int\\|string, mixed\\>, types\\: Closure\\(\\)\\: list\\<GraphQL\\\\Type\\\\Definition\\\\Type\\>, typeLoader\\: Closure\\(mixed\\)\\: \\(GraphQL\\\\Type\\\\Definition\\\\Type\\|null\\)\\} given\\.$#"
count: 1
path: src/GraphQL.php

Expand Down
2 changes: 1 addition & 1 deletion src/Support/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ protected function getFieldResolver(string $name, array $field): ?callable
};
}

if (isset($field['alias']) && \is_string($field['alias'])) {
if (isset($field['alias']) && \is_string($field['alias']) && !($this instanceof InputType)) {
$alias = $field['alias'];

return function ($type) use ($alias) {
Expand Down
19 changes: 19 additions & 0 deletions tests/Unit/GraphQLTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Rebing\GraphQL\Tests\Support\Objects\ExampleType;
use Rebing\GraphQL\Tests\Support\Objects\UpdateExampleMutation;
use Rebing\GraphQL\Tests\TestCase;
use Rebing\GraphQL\Tests\Unit\AliasArguments\Stubs\ExampleNestedValidationInputObject;

class GraphQLTest extends TestCase
{
Expand All @@ -44,6 +45,24 @@ public function testSchemaWithName(): void
self::assertArrayHasKey('Example', $schema->getTypeMap());
}

/**
* @doesNotPerformAssertions
*/
public function testSchemaIsValidWithInputFieldAliases(): void
{
$schema = GraphQL::buildSchemaFromConfig([
'query' => [
'examplesCustom' => ExamplesQuery::class,
],

'types' => [
ExampleNestedValidationInputObject::class,
],
]);

$schema->assertValid();
}

public function testSchemaWithNameReferencingClass(): void
{
$schema = GraphQL::schema('class_based');
Expand Down

0 comments on commit 106d060

Please sign in to comment.