Skip to content

Commit 829172f

Browse files
committed
Add failing test case
1 parent d0a1cd7 commit 829172f

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

tests/Integration/Schema/Directives/InjectDirectiveTest.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,54 @@ public function testCreateFromInputObjectWithWildcardInjection(): void
140140
]);
141141
}
142142

143+
public function testCanSendEmptyArray(): void
144+
{
145+
$user = factory(User::class)->create();
146+
$this->be($user);
147+
148+
$this->schema .= /* @lang GraphQL */ '
149+
type Task {
150+
id: ID!
151+
name: String!
152+
user: User @belongsTo
153+
}
154+
155+
type User {
156+
id: ID
157+
}
158+
159+
type Mutation {
160+
createTask(input: CreateTaskInput! @spread): Task @create
161+
}
162+
163+
input CreateTaskInput {
164+
name: String
165+
empty_array: [String]!
166+
user_id: ID!
167+
}
168+
';
169+
170+
$this->graphQL('
171+
mutation ($id: ID!, $emptyArray: [String]!) {
172+
createTask(input: {
173+
name: "foo"
174+
user_id: $id
175+
empty_array: $emptyArray
176+
}) {
177+
id
178+
}
179+
}
180+
', [
181+
'id' => $user->getKey(),
182+
'emptyArray' => [],
183+
])->assertJson([
184+
'data' => [
185+
'createTask' => [
186+
'id' => '1',
187+
],
188+
],
189+
]);
190+
}
143191

144192
public function testWillRejectValuesNotPlacedAtArrayWithWildcardInjection(): void
145193
{

0 commit comments

Comments
 (0)