Skip to content

Commit

Permalink
fix(graphql-printer): Object value will respect `Settings::isAlwaysMu…
Browse files Browse the repository at this point in the history
…ltilineArguments()`.
  • Loading branch information
LastDragon-ru committed Aug 29, 2023
1 parent 212b61c commit 4a8b916
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
33 changes: 27 additions & 6 deletions packages/graphql-printer/src/Blocks/Document/ValueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -327,13 +327,13 @@ public static function dataProviderSerialize(): array {
0,
Parser::valueLiteral(
<<<'STRING'
{
object: {
a: "a"
b: "b"
{
object: {
a: "a"
b: "b"
}
}
}
STRING,
STRING,
),
null,
null,
Expand Down Expand Up @@ -371,6 +371,27 @@ public static function dataProviderSerialize(): array {
null,
null,
],
ObjectValueNode::class.' (one line)' => [
<<<'STRING'
{object: {a: "a", b: "b"}}
STRING,
$settings
->setAlwaysMultilineArguments(false),
0,
0,
Parser::valueLiteral(
<<<'STRING'
{
object: {
a: "a"
b: "b"
}
}
STRING,
),
null,
null,
],
'all' => [
<<<'STRING'
{
Expand Down
3 changes: 2 additions & 1 deletion packages/graphql-printer/src/Blocks/Values/ObjectValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ protected function getEmptyValue(): string {
}

protected function isAlwaysMultiline(): bool {
return true;
return parent::isAlwaysMultiline()
|| $this->getSettings()->isAlwaysMultilineArguments();
}

protected function isNormalized(): bool {
Expand Down

0 comments on commit 4a8b916

Please sign in to comment.