Skip to content

Commit 3b7362e

Browse files
author
Jeremiah VALERIE
committed
Merge branch '0.11' into 0.12
2 parents 88cb995 + 6f4862a commit 3b7362e

File tree

3 files changed

+131
-0
lines changed

3 files changed

+131
-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.root_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: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?php
2+
3+
namespace Overblog\GraphQLBundle\Tests\Functional\DefaultValue;
4+
5+
use Overblog\GraphQLBundle\Tests\Functional\TestCase;
6+
7+
class DefaultValueTest extends TestCase
8+
{
9+
protected function setUp()
10+
{
11+
static::bootKernel(['test_case' => 'defaultValue']);
12+
}
13+
14+
public function testArgDefaultValue()
15+
{
16+
$query = 'mutation { echo }';
17+
18+
$result = $this->executeGraphQLRequest($query);
19+
20+
$this->assertTrue(empty($result['errors']));
21+
$this->assertSame('foo', $result['data']['echo']);
22+
}
23+
24+
public function testNullableDefaultValue()
25+
{
26+
$query = 'mutation { isStringNull }';
27+
28+
$result = $this->executeGraphQLRequest($query);
29+
30+
$this->assertTrue(empty($result['errors']));
31+
$this->assertTrue($result['data']['isStringNull']);
32+
}
33+
34+
public function testArgDefaultValueWithInput()
35+
{
36+
$query = 'mutation { echoUsingInput(input: {}) }';
37+
38+
$result = $this->executeGraphQLRequest($query);
39+
40+
$this->assertTrue(empty($result['errors']));
41+
$this->assertSame('foo', $result['data']['echoUsingInput']);
42+
}
43+
44+
public function testNullableDefaultValueWithInput()
45+
{
46+
$query = 'mutation { isStringNullUsingInput(input: {}) }';
47+
48+
$result = $this->executeGraphQLRequest($query);
49+
50+
$this->assertTrue(empty($result['errors']));
51+
$this->assertTrue($result['data']['isStringNullUsingInput']);
52+
}
53+
54+
public function testArgDefaultValueArgWithInput()
55+
{
56+
$query = 'mutation { echoUsingInputWithDefaultArg }';
57+
58+
$result = $this->executeGraphQLRequest($query);
59+
60+
$this->assertTrue(empty($result['errors']));
61+
$this->assertSame('bar', $result['data']['echoUsingInputWithDefaultArg']);
62+
}
63+
}

0 commit comments

Comments
 (0)