Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: build client schema have custom scalar value mixed type #1536

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Utils/BuildClientSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ private function buildScalarDef(array $scalar): ScalarType
return new CustomScalarType([
'name' => $scalar['name'],
'description' => $scalar['description'],
'serialize' => static fn ($value): string => (string) $value,
'serialize' => static fn ($value) => $value,
]);
}

Expand Down
24 changes: 24 additions & 0 deletions tests/Utils/BuildClientSchemaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1013,4 +1013,28 @@ public function testRecursiveUnion(): void
$this->expectExceptionMessage('Expected Foo to be a GraphQL Object type.');
$clientSchema->assertValid();
}

public function testCustomScalarValueMixedExecution(): void
spawnia marked this conversation as resolved.
Show resolved Hide resolved
{
$schema = BuildSchema::build('
scalar CustomScalar

type Query {
foo(bar: CustomScalar): CustomScalar
}
');

$introspection = Introspection::fromSchema($schema);
$clientSchema = BuildClientSchema::build($introspection);

$result = GraphQL::executeQuery(
$clientSchema,
'query CustomScalarObject($v: CustomScalar) { foo(bar: $v) }',
['foo' => ['baz' => 'value']],
null,
['v' => 100]
);

self::assertSame(['foo' => ['baz' => 'value']], $result->data);
}
}
Loading