Skip to content

Commit 161c0e3

Browse files
author
Jeremiah VALERIE
committed
Merge branch '0.13' into 0.14
2 parents 783018e + 5c2591e commit 161c0e3

File tree

3 files changed

+133
-0
lines changed

3 files changed

+133
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
imports:
2+
- { resource: ../config.yml }
3+
4+
overblog_graphql:
5+
definitions:
6+
config_validation: false
7+
class_namespace: "Overblog\\GraphQLBundle\\DefaultValue\\__DEFINITIONS__"
8+
schema:
9+
query: Mutation
10+
mutation: Mutation
11+
mappings:
12+
types:
13+
- type: yaml
14+
dir: "%kernel.project_dir%/config/defaultValue/mapping"
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
Mutation:
2+
type: object
3+
config:
4+
fields:
5+
echo:
6+
type: String!
7+
resolve: "@=args['output']"
8+
args:
9+
output:
10+
type: String
11+
defaultValue: 'foo'
12+
isStringNull:
13+
type: Boolean!
14+
resolve: "@=null === args.getRawArguments()['string']"
15+
args:
16+
string:
17+
type: String
18+
defaultValue: null
19+
echoUsingInput:
20+
type: String!
21+
resolve: "@=args['input']['output']"
22+
args:
23+
input:
24+
type: EchoInput!
25+
isStringNullUsingInput:
26+
type: Boolean!
27+
resolve: "@=null === args.getRawArguments()['input']['string']"
28+
args:
29+
input:
30+
type: isStringNullInput!
31+
32+
echoUsingInputWithDefaultArg:
33+
type: String!
34+
resolve: "@=args['input']['output']"
35+
args:
36+
input:
37+
type: EchoInput
38+
defaultValue: {"output": "bar"}
39+
40+
EchoInput:
41+
type: input-object
42+
config:
43+
fields:
44+
output:
45+
type: String
46+
defaultValue: 'foo'
47+
48+
isStringNullInput:
49+
type: input-object
50+
config:
51+
fields:
52+
string:
53+
type: String
54+
defaultValue: null
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Overblog\GraphQLBundle\Tests\Functional\DefaultValue;
6+
7+
use Overblog\GraphQLBundle\Tests\Functional\TestCase;
8+
9+
class DefaultValueTest extends TestCase
10+
{
11+
protected function setUp(): void
12+
{
13+
static::bootKernel(['test_case' => 'defaultValue']);
14+
}
15+
16+
public function testArgDefaultValue(): void
17+
{
18+
$query = 'mutation { echo }';
19+
20+
$result = $this->executeGraphQLRequest($query);
21+
22+
$this->assertTrue(empty($result['errors']));
23+
$this->assertSame('foo', $result['data']['echo']);
24+
}
25+
26+
public function testNullableDefaultValue(): void
27+
{
28+
$query = 'mutation { isStringNull }';
29+
30+
$result = $this->executeGraphQLRequest($query);
31+
32+
$this->assertTrue(empty($result['errors']));
33+
$this->assertTrue($result['data']['isStringNull']);
34+
}
35+
36+
public function testArgDefaultValueWithInput(): void
37+
{
38+
$query = 'mutation { echoUsingInput(input: {}) }';
39+
40+
$result = $this->executeGraphQLRequest($query);
41+
42+
$this->assertTrue(empty($result['errors']));
43+
$this->assertSame('foo', $result['data']['echoUsingInput']);
44+
}
45+
46+
public function testNullableDefaultValueWithInput(): void
47+
{
48+
$query = 'mutation { isStringNullUsingInput(input: {}) }';
49+
50+
$result = $this->executeGraphQLRequest($query);
51+
52+
$this->assertTrue(empty($result['errors']));
53+
$this->assertTrue($result['data']['isStringNullUsingInput']);
54+
}
55+
56+
public function testArgDefaultValueArgWithInput(): void
57+
{
58+
$query = 'mutation { echoUsingInputWithDefaultArg }';
59+
60+
$result = $this->executeGraphQLRequest($query);
61+
62+
$this->assertTrue(empty($result['errors']));
63+
$this->assertSame('bar', $result['data']['echoUsingInputWithDefaultArg']);
64+
}
65+
}

0 commit comments

Comments
 (0)