Skip to content

Commit c295339

Browse files
committed
Allowed arg type short syntax
Now arg type can be define like `Arg: Type` that is equivalent to `Arg: {type: Type}` Deprecated as of 0.7 the builder short syntax (`Field: Builder` equivalent to `Field: {builder: Builder}`). This will allow field type short syntax in 0.8.
1 parent 89f0068 commit c295339

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

Config/TypeWithOutputFieldsDefinition.php

+14
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,11 @@ protected function outputFieldsSelection($name)
161161
$fieldBuilderName = $field['builder'];
162162
unset($field['builder']);
163163
} elseif (is_string($field)) {
164+
@trigger_error(
165+
'The builder short syntax (Field: Builder => Field: {builder: Builder}) is deprecated as of 0.7 and will be removed in 0.8. '.
166+
'It will be replaced by the field type short syntax (Field: Type => Field: {type: Type})',
167+
E_USER_DEPRECATED
168+
);
164169
$fieldBuilderName = $field;
165170
}
166171

@@ -188,6 +193,15 @@ protected function outputFieldsSelection($name)
188193
->info('Array of possible type arguments. Each entry is expected to be an array with following keys: name (string), type')
189194
->useAttributeAsKey('name', false)
190195
->prototype('array')
196+
// Allow arg type short syntax (Arg: Type => Arg: {type: Type})
197+
->beforeNormalization()
198+
->ifTrue(function ($options) {
199+
return is_string($options);
200+
})
201+
->then(function ($options) {
202+
return ['type' => $options];
203+
})
204+
->end()
191205
->children()
192206
->append($this->typeSelection(true))
193207
->append($this->descriptionSection())

Tests/Functional/app/config/customScalar/mapping/Query.types.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ Query:
1010
config:
1111
fields:
1212
dateTime:
13-
type: "DateTime!"
13+
type: DateTime!
1414
args:
15-
dateTime:
16-
type: "DateTime"
15+
dateTime: DateTime
1716
resolve: ["Overblog\\GraphQLGenerator\\Tests\\Resolver", "getDateTime"]

Tests/Functional/app/config/global/mapping/global.types.yml

+1-6
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@ User:
2020
type: object
2121
config:
2222
fields:
23-
id:
24-
builder: "Relay::GlobalId"
25-
builderConfig:
26-
typeName: User
23+
id: "Relay::GlobalId"
2724
name:
2825
type: String
2926
interfaces: [NodeInterface]
@@ -47,8 +44,6 @@ Post:
4744
fields:
4845
id:
4946
builder: "Relay::GlobalId"
50-
builderConfig:
51-
typeName: Post
5247
text:
5348
type: String
5449
status:

0 commit comments

Comments
 (0)