We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -32,10 +32,10 @@ discard block |
||
| 32 | 32 | * |
| 33 | 33 | * @dataProvider specialTypeFieldProvider |
| 34 | 34 | */ |
| 35 | - public function testSpecialField($fieldName, ObjectType|UnionType|InterfaceType|CustomScalarType $typeWithSpecialField, callable $fieldValueRetriever = null, $strict = true): void |
|
| 35 | + public function testSpecialField($fieldName, ObjectType | UnionType | InterfaceType | CustomScalarType $typeWithSpecialField, callable $fieldValueRetriever = null, $strict = true): void |
|
| 36 | 36 | { |
| 37 | 37 | if (null === $fieldValueRetriever) { |
| 38 | - $fieldValueRetriever = fn (ObjectType|UnionType|InterfaceType|CustomScalarType $type, $fieldName) => $type->config[$fieldName]; |
|
| 38 | + $fieldValueRetriever = fn(ObjectType | UnionType | InterfaceType | CustomScalarType $type, $fieldName) => $type->config[$fieldName]; |
|
| 39 | 39 | } |
| 40 | 40 | $expected = static function (): void { |
| 41 | 41 | }; |
@@ -68,8 +68,8 @@ discard block |
||
| 68 | 68 | ]; |
| 69 | 69 | }, |
| 70 | 70 | ]); |
| 71 | - $barResolver = static fn () => 'bar'; |
|
| 72 | - $bazResolver = static fn () => 'baz'; |
|
| 71 | + $barResolver = static fn() => 'bar'; |
|
| 72 | + $bazResolver = static fn() => 'baz'; |
|
| 73 | 73 | |
| 74 | 74 | $this->decorate( |
| 75 | 75 | [$objectType->name => $objectType], |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | [$objectType->name => $objectType], |
| 105 | 105 | [ |
| 106 | 106 | $objectType->name => [ |
| 107 | - 'bar' => fn ($value, $args) => $args, |
|
| 107 | + 'bar' => fn($value, $args) => $args, |
|
| 108 | 108 | ], |
| 109 | 109 | ] |
| 110 | 110 | ); |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | |
| 194 | 194 | public function testCustomScalarTypeUnknownField(): void |
| 195 | 195 | { |
| 196 | - $customScalarType = new CustomScalarType(['name' => 'Foo', 'scalarType' => Type::string(), 'serialize' => fn (mixed $input): mixed => '']); |
|
| 196 | + $customScalarType = new CustomScalarType(['name' => 'Foo', 'scalarType' => Type::string(), 'serialize' => fn(mixed $input): mixed => '']); |
|
| 197 | 197 | $this->assertDecorateException( |
| 198 | 198 | [$customScalarType->name => $customScalarType], |
| 199 | 199 | [ |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | |
| 246 | 246 | public function specialTypeFieldProvider(): array |
| 247 | 247 | { |
| 248 | - $objectWithResolveField = new ObjectType(['name' => 'Bar', 'fields' => [], 'resolveField' => fn () => '']); |
|
| 248 | + $objectWithResolveField = new ObjectType(['name' => 'Bar', 'fields' => [], 'resolveField' => fn() => '']); |
|
| 249 | 249 | |
| 250 | 250 | return [ |
| 251 | 251 | // isTypeOf |
@@ -254,18 +254,18 @@ discard block |
||
| 254 | 254 | [ |
| 255 | 255 | ResolverMapInterface::RESOLVE_FIELD, |
| 256 | 256 | $objectWithResolveField, |
| 257 | - fn (ObjectType $type) => $type->resolveFieldFn, |
|
| 257 | + fn(ObjectType $type) => $type->resolveFieldFn, |
|
| 258 | 258 | false, |
| 259 | 259 | ], |
| 260 | 260 | [ResolverMapInterface::RESOLVE_FIELD, $objectWithResolveField, null, false], |
| 261 | 261 | // resolveType |
| 262 | - [ResolverMapInterface::RESOLVE_TYPE, new UnionType(['name' => 'Baz', 'resolveType' => fn () => '', 'types' => []])], |
|
| 263 | - [ResolverMapInterface::RESOLVE_TYPE, new InterfaceType(['name' => 'Baz', 'fields' => [], 'resolveType' => fn (mixed $objectValue, mixed $context, ResolveInfo $resolveInfo): string => ''])], |
|
| 262 | + [ResolverMapInterface::RESOLVE_TYPE, new UnionType(['name' => 'Baz', 'resolveType' => fn() => '', 'types' => []])], |
|
| 263 | + [ResolverMapInterface::RESOLVE_TYPE, new InterfaceType(['name' => 'Baz', 'fields' => [], 'resolveType' => fn(mixed $objectValue, mixed $context, ResolveInfo $resolveInfo): string => ''])], |
|
| 264 | 264 | // custom scalar |
| 265 | - [ResolverMapInterface::SERIALIZE, new CustomScalarType(['name' => 'Custom', 'scalarType' => Type::string(), 'serialize' => fn (mixed $input): mixed => ''])], |
|
| 266 | - [ResolverMapInterface::PARSE_VALUE, new CustomScalarType(['name' => 'Custom', 'scalarType' => Type::string(), 'serialize' => fn (mixed $input): mixed => '', 'parseValue' => fn (mixed $input): mixed => ''])], |
|
| 267 | - [ResolverMapInterface::PARSE_LITERAL, new CustomScalarType(['name' => 'Custom', 'scalarType' => Type::string(), 'serialize' => fn (mixed $input): mixed => '', 'parseLiteral' => fn (Node $a, array|null $b): mixed => ''])], |
|
| 268 | - [ResolverMapInterface::SCALAR_TYPE, new CustomScalarType(['name' => 'Custom', 'scalarType' => Type::string(), 'serialize' => fn (mixed $input): mixed => ''])], |
|
| 265 | + [ResolverMapInterface::SERIALIZE, new CustomScalarType(['name' => 'Custom', 'scalarType' => Type::string(), 'serialize' => fn(mixed $input): mixed => ''])], |
|
| 266 | + [ResolverMapInterface::PARSE_VALUE, new CustomScalarType(['name' => 'Custom', 'scalarType' => Type::string(), 'serialize' => fn(mixed $input): mixed => '', 'parseValue' => fn(mixed $input): mixed => ''])], |
|
| 267 | + [ResolverMapInterface::PARSE_LITERAL, new CustomScalarType(['name' => 'Custom', 'scalarType' => Type::string(), 'serialize' => fn(mixed $input): mixed => '', 'parseLiteral' => fn(Node $a, array | null $b): mixed => ''])], |
|
| 268 | + [ResolverMapInterface::SCALAR_TYPE, new CustomScalarType(['name' => 'Custom', 'scalarType' => Type::string(), 'serialize' => fn(mixed $input): mixed => ''])], |
|
| 269 | 269 | ]; |
| 270 | 270 | } |
| 271 | 271 | |
@@ -22,12 +22,12 @@ discard block |
||
| 22 | 22 | public function testScalarTypeConfig(): void |
| 23 | 23 | { |
| 24 | 24 | $this->assertScalarTypeConfig(new YearScalarType()); |
| 25 | - $this->assertScalarTypeConfig(fn () => new YearScalarType()); |
|
| 25 | + $this->assertScalarTypeConfig(fn() => new YearScalarType()); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | public function testWithoutScalarTypeConfig(): void |
| 29 | 29 | { |
| 30 | - $genericFunc = fn ($value) => $value; |
|
| 30 | + $genericFunc = fn($value) => $value; |
|
| 31 | 31 | /** @phpstan-ignore-next-line */ |
| 32 | 32 | $type = new CustomScalarType([ |
| 33 | 33 | 'serialize' => $genericFunc, |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | ScalarType::class, |
| 58 | 58 | $got |
| 59 | 59 | )); |
| 60 | - $type = new CustomScalarType(['name' => $name, 'scalarType' => $scalarType, 'serialize' => fn (mixed $input): mixed => '']); |
|
| 60 | + $type = new CustomScalarType(['name' => $name, 'scalarType' => $scalarType, 'serialize' => fn(mixed $input): mixed => '']); |
|
| 61 | 61 | $type->assertValid(); |
| 62 | 62 | } |
| 63 | 63 | |
@@ -66,11 +66,11 @@ discard block |
||
| 66 | 66 | yield [false, 'false']; |
| 67 | 67 | yield [new stdClass(), 'instance of stdClass']; |
| 68 | 68 | yield [ |
| 69 | - fn () => false, |
|
| 69 | + fn() => false, |
|
| 70 | 70 | 'false', |
| 71 | 71 | ]; |
| 72 | 72 | yield [ |
| 73 | - fn () => new stdClass(), |
|
| 73 | + fn() => new stdClass(), |
|
| 74 | 74 | 'instance of stdClass', |
| 75 | 75 | ]; |
| 76 | 76 | } |
@@ -84,9 +84,9 @@ discard block |
||
| 84 | 84 | { |
| 85 | 85 | $type = new CustomScalarType([ |
| 86 | 86 | 'scalarType' => $scalarType, |
| 87 | - 'serialize' => fn () => 'serialize', |
|
| 88 | - 'parseValue' => fn () => 'parseValue', |
|
| 89 | - 'parseLiteral' => fn () => 'parseLiteral', |
|
| 87 | + 'serialize' => fn() => 'serialize', |
|
| 88 | + 'parseValue' => fn() => 'parseValue', |
|
| 89 | + 'parseLiteral' => fn() => 'parseLiteral', |
|
| 90 | 90 | ]); |
| 91 | 91 | |
| 92 | 92 | $this->assertSame('50 AC', $type->serialize(50)); |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | return parent::$type($value); |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - $scalarType = match (true) { |
|
| 80 | + $scalarType = match(true) { |
|
| 81 | 81 | $this->config['scalarType'] instanceof ScalarType => $this->config['scalarType'], |
| 82 | 82 | is_callable($this->config['scalarType']) => $this->config['scalarType'](), |
| 83 | 83 | default => $this->config['scalarType'], |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | return; |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - $scalarType = match (true) { |
|
| 97 | + $scalarType = match(true) { |
|
| 98 | 98 | $this->config['scalarType'] instanceof ScalarType => $this->config['scalarType'], |
| 99 | 99 | is_callable($this->config['scalarType']) => $this->config['scalarType'](), |
| 100 | 100 | default => $this->config['scalarType'], |
@@ -26,67 +26,3 @@ |
||
| 26 | 26 | $this->assertSame([['node' => ['username' => 'user1']]], $result['data']['users']['edges']); |
| 27 | 27 | |
| 28 | 28 | $query = <<<'EOF' |
| 29 | - mutation M { |
|
| 30 | - addUser(input: {username: "user1"}) { |
|
| 31 | - user { |
|
| 32 | - username |
|
| 33 | - } |
|
| 34 | - } |
|
| 35 | - } |
|
| 36 | - EOF; |
|
| 37 | - |
|
| 38 | - $expectedData = [ |
|
| 39 | - 'addUser' => [ |
|
| 40 | - 'user' => ['username' => 'user1'], |
|
| 41 | - ], |
|
| 42 | - ]; |
|
| 43 | - |
|
| 44 | - $this->assertGraphQL($query, $expectedData, null, [], 'public'); |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - public function testInternalSchema(): void |
|
| 48 | - { |
|
| 49 | - $result = $this->executeGraphQLRequest('{bar foo}', [], 'internal'); |
|
| 50 | - $this->assertSame('bar', $result['data']['bar']); |
|
| 51 | - $this->assertSame('foo', $result['data']['foo']); |
|
| 52 | - $this->assertSchemaQueryTypeName('InternalQuery'); |
|
| 53 | - |
|
| 54 | - $result = $this->executeGraphQLRequest('{users{edges{node{username email}}}}', [], 'internal'); |
|
| 55 | - $this->assertSame([['node' => ['username' => 'user1', 'email' => 'topsecret']]], $result['data']['users']['edges']); |
|
| 56 | - |
|
| 57 | - $query = <<<'EOF' |
|
| 58 | - mutation M { |
|
| 59 | - addUser(input: {username: "user1"}) { |
|
| 60 | - user { |
|
| 61 | - username |
|
| 62 | ||
| 63 | - } |
|
| 64 | - } |
|
| 65 | - } |
|
| 66 | - EOF; |
|
| 67 | - |
|
| 68 | - $expectedData = [ |
|
| 69 | - 'addUser' => [ |
|
| 70 | - 'user' => ['username' => 'user1', 'email' => 'email1'], |
|
| 71 | - ], |
|
| 72 | - ]; |
|
| 73 | - |
|
| 74 | - $this->assertGraphQL($query, $expectedData, null, [], 'internal'); |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - public function testUnknownTypeShouldThrowAnUnresolvableException(): void |
|
| 78 | - { |
|
| 79 | - // @phpstan-ignore-next-line |
|
| 80 | - $schema = $this->getContainer()->get('overblog_graphql.request_executor')->getSchema('public'); |
|
| 81 | - $this->expectException(UnresolvableException::class); |
|
| 82 | - $this->expectExceptionMessage('Could not find type with alias "unknown". Did you forget to define it?'); |
|
| 83 | - $schema->getType('unknown'); |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - private function assertSchemaQueryTypeName(string $typeName): void |
|
| 87 | - { |
|
| 88 | - // @phpstan-ignore-next-line |
|
| 89 | - $query = $this->getContainer()->get('overblog_graphql.type_resolver')->resolve($typeName); |
|
| 90 | - $this->assertSame('Query', $query->name); |
|
| 91 | - } |
|
| 92 | -} |
|
@@ -26,67 +26,3 @@ |
||
| 26 | 26 | $this->assertSame([['node' => ['username' => 'user1']]], $result['data']['users']['edges']); |
| 27 | 27 | |
| 28 | 28 | $query = <<<'EOF' |
| 29 | - mutation M { |
|
| 30 | - addUser(input: {username: "user1"}) { |
|
| 31 | - user { |
|
| 32 | - username |
|
| 33 | - } |
|
| 34 | - } |
|
| 35 | - } |
|
| 36 | - EOF; |
|
| 37 | - |
|
| 38 | - $expectedData = [ |
|
| 39 | - 'addUser' => [ |
|
| 40 | - 'user' => ['username' => 'user1'], |
|
| 41 | - ], |
|
| 42 | - ]; |
|
| 43 | - |
|
| 44 | - $this->assertGraphQL($query, $expectedData, null, [], 'public'); |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - public function testInternalSchema(): void |
|
| 48 | - { |
|
| 49 | - $result = $this->executeGraphQLRequest('{bar foo}', [], 'internal'); |
|
| 50 | - $this->assertSame('bar', $result['data']['bar']); |
|
| 51 | - $this->assertSame('foo', $result['data']['foo']); |
|
| 52 | - $this->assertSchemaQueryTypeName('InternalQuery'); |
|
| 53 | - |
|
| 54 | - $result = $this->executeGraphQLRequest('{users{edges{node{username email}}}}', [], 'internal'); |
|
| 55 | - $this->assertSame([['node' => ['username' => 'user1', 'email' => 'topsecret']]], $result['data']['users']['edges']); |
|
| 56 | - |
|
| 57 | - $query = <<<'EOF' |
|
| 58 | - mutation M { |
|
| 59 | - addUser(input: {username: "user1"}) { |
|
| 60 | - user { |
|
| 61 | - username |
|
| 62 | ||
| 63 | - } |
|
| 64 | - } |
|
| 65 | - } |
|
| 66 | - EOF; |
|
| 67 | - |
|
| 68 | - $expectedData = [ |
|
| 69 | - 'addUser' => [ |
|
| 70 | - 'user' => ['username' => 'user1', 'email' => 'email1'], |
|
| 71 | - ], |
|
| 72 | - ]; |
|
| 73 | - |
|
| 74 | - $this->assertGraphQL($query, $expectedData, null, [], 'internal'); |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - public function testUnknownTypeShouldThrowAnUnresolvableException(): void |
|
| 78 | - { |
|
| 79 | - // @phpstan-ignore-next-line |
|
| 80 | - $schema = $this->getContainer()->get('overblog_graphql.request_executor')->getSchema('public'); |
|
| 81 | - $this->expectException(UnresolvableException::class); |
|
| 82 | - $this->expectExceptionMessage('Could not find type with alias "unknown". Did you forget to define it?'); |
|
| 83 | - $schema->getType('unknown'); |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - private function assertSchemaQueryTypeName(string $typeName): void |
|
| 87 | - { |
|
| 88 | - // @phpstan-ignore-next-line |
|
| 89 | - $query = $this->getContainer()->get('overblog_graphql.type_resolver')->resolve($typeName); |
|
| 90 | - $this->assertSame('Query', $query->name); |
|
| 91 | - } |
|
| 92 | -} |
|
@@ -26,67 +26,3 @@ |
||
| 26 | 26 | $this->assertSame([['node' => ['username' => 'user1']]], $result['data']['users']['edges']); |
| 27 | 27 | |
| 28 | 28 | $query = <<<'EOF' |
| 29 | - mutation M { |
|
| 30 | - addUser(input: {username: "user1"}) { |
|
| 31 | - user { |
|
| 32 | - username |
|
| 33 | - } |
|
| 34 | - } |
|
| 35 | - } |
|
| 36 | - EOF; |
|
| 37 | - |
|
| 38 | - $expectedData = [ |
|
| 39 | - 'addUser' => [ |
|
| 40 | - 'user' => ['username' => 'user1'], |
|
| 41 | - ], |
|
| 42 | - ]; |
|
| 43 | - |
|
| 44 | - $this->assertGraphQL($query, $expectedData, null, [], 'public'); |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - public function testInternalSchema(): void |
|
| 48 | - { |
|
| 49 | - $result = $this->executeGraphQLRequest('{bar foo}', [], 'internal'); |
|
| 50 | - $this->assertSame('bar', $result['data']['bar']); |
|
| 51 | - $this->assertSame('foo', $result['data']['foo']); |
|
| 52 | - $this->assertSchemaQueryTypeName('InternalQuery'); |
|
| 53 | - |
|
| 54 | - $result = $this->executeGraphQLRequest('{users{edges{node{username email}}}}', [], 'internal'); |
|
| 55 | - $this->assertSame([['node' => ['username' => 'user1', 'email' => 'topsecret']]], $result['data']['users']['edges']); |
|
| 56 | - |
|
| 57 | - $query = <<<'EOF' |
|
| 58 | - mutation M { |
|
| 59 | - addUser(input: {username: "user1"}) { |
|
| 60 | - user { |
|
| 61 | - username |
|
| 62 | ||
| 63 | - } |
|
| 64 | - } |
|
| 65 | - } |
|
| 66 | - EOF; |
|
| 67 | - |
|
| 68 | - $expectedData = [ |
|
| 69 | - 'addUser' => [ |
|
| 70 | - 'user' => ['username' => 'user1', 'email' => 'email1'], |
|
| 71 | - ], |
|
| 72 | - ]; |
|
| 73 | - |
|
| 74 | - $this->assertGraphQL($query, $expectedData, null, [], 'internal'); |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - public function testUnknownTypeShouldThrowAnUnresolvableException(): void |
|
| 78 | - { |
|
| 79 | - // @phpstan-ignore-next-line |
|
| 80 | - $schema = $this->getContainer()->get('overblog_graphql.request_executor')->getSchema('public'); |
|
| 81 | - $this->expectException(UnresolvableException::class); |
|
| 82 | - $this->expectExceptionMessage('Could not find type with alias "unknown". Did you forget to define it?'); |
|
| 83 | - $schema->getType('unknown'); |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - private function assertSchemaQueryTypeName(string $typeName): void |
|
| 87 | - { |
|
| 88 | - // @phpstan-ignore-next-line |
|
| 89 | - $query = $this->getContainer()->get('overblog_graphql.type_resolver')->resolve($typeName); |
|
| 90 | - $this->assertSame('Query', $query->name); |
|
| 91 | - } |
|
| 92 | -} |
|
@@ -26,67 +26,3 @@ |
||
| 26 | 26 | $this->assertSame([['node' => ['username' => 'user1']]], $result['data']['users']['edges']); |
| 27 | 27 | |
| 28 | 28 | $query = <<<'EOF' |
| 29 | - mutation M { |
|
| 30 | - addUser(input: {username: "user1"}) { |
|
| 31 | - user { |
|
| 32 | - username |
|
| 33 | - } |
|
| 34 | - } |
|
| 35 | - } |
|
| 36 | - EOF; |
|
| 37 | - |
|
| 38 | - $expectedData = [ |
|
| 39 | - 'addUser' => [ |
|
| 40 | - 'user' => ['username' => 'user1'], |
|
| 41 | - ], |
|
| 42 | - ]; |
|
| 43 | - |
|
| 44 | - $this->assertGraphQL($query, $expectedData, null, [], 'public'); |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - public function testInternalSchema(): void |
|
| 48 | - { |
|
| 49 | - $result = $this->executeGraphQLRequest('{bar foo}', [], 'internal'); |
|
| 50 | - $this->assertSame('bar', $result['data']['bar']); |
|
| 51 | - $this->assertSame('foo', $result['data']['foo']); |
|
| 52 | - $this->assertSchemaQueryTypeName('InternalQuery'); |
|
| 53 | - |
|
| 54 | - $result = $this->executeGraphQLRequest('{users{edges{node{username email}}}}', [], 'internal'); |
|
| 55 | - $this->assertSame([['node' => ['username' => 'user1', 'email' => 'topsecret']]], $result['data']['users']['edges']); |
|
| 56 | - |
|
| 57 | - $query = <<<'EOF' |
|
| 58 | - mutation M { |
|
| 59 | - addUser(input: {username: "user1"}) { |
|
| 60 | - user { |
|
| 61 | - username |
|
| 62 | ||
| 63 | - } |
|
| 64 | - } |
|
| 65 | - } |
|
| 66 | - EOF; |
|
| 67 | - |
|
| 68 | - $expectedData = [ |
|
| 69 | - 'addUser' => [ |
|
| 70 | - 'user' => ['username' => 'user1', 'email' => 'email1'], |
|
| 71 | - ], |
|
| 72 | - ]; |
|
| 73 | - |
|
| 74 | - $this->assertGraphQL($query, $expectedData, null, [], 'internal'); |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - public function testUnknownTypeShouldThrowAnUnresolvableException(): void |
|
| 78 | - { |
|
| 79 | - // @phpstan-ignore-next-line |
|
| 80 | - $schema = $this->getContainer()->get('overblog_graphql.request_executor')->getSchema('public'); |
|
| 81 | - $this->expectException(UnresolvableException::class); |
|
| 82 | - $this->expectExceptionMessage('Could not find type with alias "unknown". Did you forget to define it?'); |
|
| 83 | - $schema->getType('unknown'); |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - private function assertSchemaQueryTypeName(string $typeName): void |
|
| 87 | - { |
|
| 88 | - // @phpstan-ignore-next-line |
|
| 89 | - $query = $this->getContainer()->get('overblog_graphql.type_resolver')->resolve($typeName); |
|
| 90 | - $this->assertSame('Query', $query->name); |
|
| 91 | - } |
|
| 92 | -} |
|
@@ -26,67 +26,3 @@ |
||
| 26 | 26 | $this->assertSame([['node' => ['username' => 'user1']]], $result['data']['users']['edges']); |
| 27 | 27 | |
| 28 | 28 | $query = <<<'EOF' |
| 29 | - mutation M { |
|
| 30 | - addUser(input: {username: "user1"}) { |
|
| 31 | - user { |
|
| 32 | - username |
|
| 33 | - } |
|
| 34 | - } |
|
| 35 | - } |
|
| 36 | - EOF; |
|
| 37 | - |
|
| 38 | - $expectedData = [ |
|
| 39 | - 'addUser' => [ |
|
| 40 | - 'user' => ['username' => 'user1'], |
|
| 41 | - ], |
|
| 42 | - ]; |
|
| 43 | - |
|
| 44 | - $this->assertGraphQL($query, $expectedData, null, [], 'public'); |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - public function testInternalSchema(): void |
|
| 48 | - { |
|
| 49 | - $result = $this->executeGraphQLRequest('{bar foo}', [], 'internal'); |
|
| 50 | - $this->assertSame('bar', $result['data']['bar']); |
|
| 51 | - $this->assertSame('foo', $result['data']['foo']); |
|
| 52 | - $this->assertSchemaQueryTypeName('InternalQuery'); |
|
| 53 | - |
|
| 54 | - $result = $this->executeGraphQLRequest('{users{edges{node{username email}}}}', [], 'internal'); |
|
| 55 | - $this->assertSame([['node' => ['username' => 'user1', 'email' => 'topsecret']]], $result['data']['users']['edges']); |
|
| 56 | - |
|
| 57 | - $query = <<<'EOF' |
|
| 58 | - mutation M { |
|
| 59 | - addUser(input: {username: "user1"}) { |
|
| 60 | - user { |
|
| 61 | - username |
|
| 62 | ||
| 63 | - } |
|
| 64 | - } |
|
| 65 | - } |
|
| 66 | - EOF; |
|
| 67 | - |
|
| 68 | - $expectedData = [ |
|
| 69 | - 'addUser' => [ |
|
| 70 | - 'user' => ['username' => 'user1', 'email' => 'email1'], |
|
| 71 | - ], |
|
| 72 | - ]; |
|
| 73 | - |
|
| 74 | - $this->assertGraphQL($query, $expectedData, null, [], 'internal'); |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - public function testUnknownTypeShouldThrowAnUnresolvableException(): void |
|
| 78 | - { |
|
| 79 | - // @phpstan-ignore-next-line |
|
| 80 | - $schema = $this->getContainer()->get('overblog_graphql.request_executor')->getSchema('public'); |
|
| 81 | - $this->expectException(UnresolvableException::class); |
|
| 82 | - $this->expectExceptionMessage('Could not find type with alias "unknown". Did you forget to define it?'); |
|
| 83 | - $schema->getType('unknown'); |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - private function assertSchemaQueryTypeName(string $typeName): void |
|
| 87 | - { |
|
| 88 | - // @phpstan-ignore-next-line |
|
| 89 | - $query = $this->getContainer()->get('overblog_graphql.type_resolver')->resolve($typeName); |
|
| 90 | - $this->assertSame('Query', $query->name); |
|
| 91 | - } |
|
| 92 | -} |
|
@@ -106,13 +106,13 @@ |
||
| 106 | 106 | protected function createGraphQLServices(array $services = []): GraphQLServices |
| 107 | 107 | { |
| 108 | 108 | $locateableServices = [ |
| 109 | - TypeResolver::class => fn () => $this->createMock(TypeResolver::class), |
|
| 110 | - QueryResolver::class => fn () => $this->createMock(QueryResolver::class), |
|
| 111 | - MutationResolver::class => fn () => $$this->createMock(MutationResolver::class), |
|
| 109 | + TypeResolver::class => fn() => $this->createMock(TypeResolver::class), |
|
| 110 | + QueryResolver::class => fn() => $this->createMock(QueryResolver::class), |
|
| 111 | + MutationResolver::class => fn() => $$this->createMock(MutationResolver::class), |
|
| 112 | 112 | ]; |
| 113 | 113 | |
| 114 | 114 | foreach ($services as $id => $service) { |
| 115 | - $locateableServices[$id] = fn () => $service; |
|
| 115 | + $locateableServices[$id] = fn() => $service; |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | return new GraphQLServices($locateableServices); |
@@ -71,7 +71,7 @@ |
||
| 71 | 71 | $alias = $container->getAlias($id); |
| 72 | 72 | $id = (string) $alias; |
| 73 | 73 | $definition = $container->getDefinition($id); |
| 74 | - } catch (ServiceNotFoundException|InvalidArgumentException $e) { |
|
| 74 | + } catch (ServiceNotFoundException | InvalidArgumentException $e) { |
|
| 75 | 75 | if ($throw) { |
| 76 | 76 | throw $e; |
| 77 | 77 | } |