Skip to content

Commit 05e4e6e

Browse files
author
Jeremiah VALERIE
committed
Add type shorthand failling test
1 parent cc3a0fe commit 05e4e6e

File tree

3 files changed

+84
-0
lines changed

3 files changed

+84
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
imports:
2+
- { resource: ../config.yml }
3+
framework:
4+
annotations: true
5+
validation:
6+
enabled: true
7+
enable_annotations: true
8+
9+
overblog_graphql:
10+
errors_handler:
11+
debug: true
12+
definitions:
13+
class_namespace: "Overblog\\GraphQLBundle\\TypeShorthand\\__DEFINITIONS__"
14+
schema:
15+
query: RootQuery
16+
mappings:
17+
types:
18+
-
19+
type: yaml
20+
dir: "%kernel.project_dir%/config/typeShorthand/mapping"
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
RootQuery:
2+
type: object
3+
config:
4+
fields:
5+
user:
6+
type: User!
7+
args:
8+
auth:
9+
type: AuthInput!
10+
validation: cascade
11+
resolve: >
12+
@={
13+
"username": args["auth"]["username"],
14+
"address": {
15+
"street": args["auth"]["username"] ~ " foo street",
16+
"zipcode": "12345"
17+
}
18+
}
19+
20+
AuthInput:
21+
type: input-object
22+
config:
23+
fields:
24+
username:
25+
type: String!
26+
validation:
27+
- NotBlank: ~
28+
password: String!
29+
User:
30+
type: object
31+
config:
32+
fields:
33+
username: String!
34+
address: Address!
35+
36+
Address:
37+
type: object
38+
config:
39+
fields:
40+
street: String!
41+
zipcode: String!
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Overblog\GraphQLBundle\Tests\Functional\AutoConfigure;
6+
7+
use Overblog\GraphQLBundle\Tests\Functional\TestCase;
8+
9+
class TypeShorthandTest extends TestCase
10+
{
11+
protected function setUp(): void
12+
{
13+
static::bootKernel(['test_case' => 'typeShorthand']);
14+
}
15+
16+
public function testQuery(): void
17+
{
18+
$query = 'query { user(auth: {username: "bar", password: "baz"}) {username, address {street, zipcode}} }';
19+
$expectedData = ['user' => ['username' => 'bar', 'address' => ['street' => 'bar foo street', 'zipcode' => '12345']]];
20+
21+
$this->assertGraphQL($query, $expectedData);
22+
}
23+
}

0 commit comments

Comments
 (0)