Skip to content

Commit cbab95c

Browse files
committed
use scalar json
1 parent c009cc6 commit cbab95c

3 files changed

Lines changed: 13 additions & 2 deletions

File tree

src/Generator/Spec/GraphQL.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ public function generate(SpecificationInterface $specification): Generator\Code\
5858

5959
$result = '';
6060

61+
$result.= 'scalar JSON' . "\n";
62+
$result.= 'scalar JSONObject' . "\n";
63+
$result.= "\n";
6164
$result.= 'schema {' . "\n";
6265
$result.= ' query: Query' . "\n";
6366
$result.= '}' . "\n";
@@ -92,9 +95,11 @@ private function toArguments(string $operationName, OperationInterface $operatio
9295
$arguments[] = $argumentName . ': ' . $this->toType($argument->getSchema());
9396
}
9497

98+
$args = count($arguments) > 0 ? '(' . implode(', ', $arguments) . ')' : '';
99+
95100
$return = $this->toType($operation->getReturn()->getSchema());
96101

97-
return $methodName . '(' . implode(', ', $arguments) . '): ' . $return;
102+
return $methodName . $args . ': ' . $return;
98103
}
99104

100105
private function toType(ContentType|TypeInterface $schema): ?string

tests/Generator/Spec/resource/graphql.graphql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
scalar JSON
2+
scalar JSONObject
3+
14
schema {
25
query: Query
36
}

tests/Generator/Spec/resource/graphql_collection.graphql

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
scalar JSON
2+
scalar JSONObject
3+
14
schema {
25
query: Query
36
}
47

58
type Query {
6-
fooBarGet(): EntryCollection
9+
fooBarGet: EntryCollection
710
barFind(foo: String): EntryCollection
811
fooBazGet(year: String): EntryCollection
912
}

0 commit comments

Comments
 (0)