|
54 | 54 | use TheCodingMachine\GraphQLite\Fixtures\TestTypeWithPrefetchMethod; |
55 | 55 | use TheCodingMachine\GraphQLite\Fixtures\TestTypeWithSourceFieldInterface; |
56 | 56 | use TheCodingMachine\GraphQLite\Fixtures\TestTypeWithSourceFieldInvalidParameterAnnotation; |
| 57 | +use TheCodingMachine\GraphQLite\Fixtures\TestSourceName; |
| 58 | +use TheCodingMachine\GraphQLite\Fixtures\TestSourceNameType; |
57 | 59 | use TheCodingMachine\GraphQLite\Mappers\CannotMapTypeException; |
58 | 60 | use TheCodingMachine\GraphQLite\Mappers\CannotMapTypeExceptionInterface; |
59 | 61 | use TheCodingMachine\GraphQLite\Middlewares\AuthorizationFieldMiddleware; |
@@ -253,6 +255,7 @@ public function testSourceField(): void |
253 | 255 | $this->assertInstanceOf(ObjectType::class, $fields['sibling']->getType()->getWrappedType()); |
254 | 256 | $this->assertSame('TestObject', $fields['sibling']->getType()->getWrappedType()->name); |
255 | 257 | $this->assertSame('This is a test summary', $fields['test']->description); |
| 258 | + $this->assertSame('Test SourceField description', $fields['sibling']->description); |
256 | 259 | } |
257 | 260 |
|
258 | 261 | public function testSourceFieldOnSelfType(): void |
@@ -777,6 +780,7 @@ public function testMagicField(): void |
777 | 780 | $this->assertCount(1, $fields); |
778 | 781 | $query = $fields['foo']; |
779 | 782 | $this->assertSame('foo', $query->name); |
| 783 | + $this->assertSame('Test MagicField description', $query->description); |
780 | 784 |
|
781 | 785 | $resolve = $query->resolveFn; |
782 | 786 | $result = $resolve(new TestTypeWithMagicProperty(), [], null, $this->createMock(ResolveInfo::class)); |
@@ -804,4 +808,26 @@ public function testProxyClassWithMagicPropertyOfPhpType(): void |
804 | 808 |
|
805 | 809 | $this->assertSame('foo', $result); |
806 | 810 | } |
| 811 | + |
| 812 | + public function testSourceNameInSourceAndMagicFields(): void |
| 813 | + { |
| 814 | + $controller = new TestSourceNameType(); |
| 815 | + $queryProvider = $this->buildFieldsBuilder(); |
| 816 | + $fields = $queryProvider->getFields($controller); |
| 817 | + $source = new TestSourceName('foo value', 'bar value'); |
| 818 | + |
| 819 | + $this->assertCount(2, $fields); |
| 820 | + |
| 821 | + $query = $fields['foo2']; |
| 822 | + $this->assertSame('foo2', $query->name); |
| 823 | + $resolve = $query->resolveFn; |
| 824 | + $result = $resolve($source, [], null, $this->createMock(ResolveInfo::class)); |
| 825 | + $this->assertSame('foo value', $result); |
| 826 | + |
| 827 | + $query = $fields['bar2']; |
| 828 | + $this->assertSame('bar2', $query->name); |
| 829 | + $resolve = $query->resolveFn; |
| 830 | + $result = $resolve($source, [], null, $this->createMock(ResolveInfo::class)); |
| 831 | + $this->assertSame('bar value', $result); |
| 832 | + } |
807 | 833 | } |
0 commit comments