Skip to content

Commit 2c3ba7c

Browse files
committed
FieldMiddlewarePipe injection is broken
No services are injected in @FieldMiddlewarePipe. As a result, the @Logged and @right annotations are broken. We might gain some stability by migrating to SchemaFactory usage in the bundle. This PR starts with a failing test. Closes #18
1 parent ee83926 commit 2c3ba7c

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

Tests/Fixtures/Controller/TestGraphqlController.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
use GraphQL\Error\Error;
88
use Porpaginas\Arrays\ArrayResult;
9+
use TheCodingMachine\GraphQLite\Annotations\FailWith;
10+
use TheCodingMachine\GraphQLite\Annotations\Logged;
911
use TheCodingMachine\Graphqlite\Bundle\Tests\Fixtures\Entities\Contact;
1012
use TheCodingMachine\Graphqlite\Bundle\Tests\Fixtures\Entities\Product;
1113
use TheCodingMachine\GraphQLite\Annotations\Mutation;
@@ -66,4 +68,15 @@ public function triggerException(int $code = 0): string
6668
{
6769
throw new MyException('Boom', $code);
6870
}
71+
72+
/**
73+
* @Query()
74+
* @Logged()
75+
* @FailWith(null)
76+
* @return string
77+
*/
78+
public function loggedQuery(): string
79+
{
80+
return 'foo';
81+
}
6982
}

Tests/FunctionalTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,4 +125,25 @@ public function testErrors()
125125

126126
$this->assertSame(404, $response->getStatusCode(), $response->getContent());
127127
}
128+
129+
public function testLoggedMiddleware()
130+
{
131+
$kernel = new GraphqliteTestingKernel('test', true);
132+
$kernel->boot();
133+
134+
$request = Request::create('/graphql', 'GET', ['query' => '
135+
{
136+
loggedQuery
137+
}']);
138+
139+
$response = $kernel->handle($request);
140+
141+
$result = json_decode($response->getContent(), true);
142+
143+
$this->assertSame([
144+
'data' => [
145+
'loggedQuery' => null
146+
]
147+
], $result);
148+
}
128149
}

0 commit comments

Comments
 (0)