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 date scalar try to parse Illuminate\\Support\\Carbon as string #2470

Merged
merged 8 commits into from
Mar 1, 2024
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ You can find and compare releases at the [GitHub release page](https://github.co

## Unreleased

### Fixed

- Fix `Date` scalar trying to parse `Illuminate\Support\Carbon` as `string` https://github.com/nuwave/lighthouse/pull/2470

## v6.34.0

### Added
Expand Down
3 changes: 1 addition & 2 deletions src/Schema/AST/ASTBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,7 @@ protected function missingBaseDefinition(string $typeName, ObjectTypeExtensionNo
protected function assertExtensionMatchesDefinition(
ObjectTypeExtensionNode|InputObjectTypeExtensionNode|InterfaceTypeExtensionNode|ScalarTypeExtensionNode|EnumTypeExtensionNode|UnionTypeExtensionNode $extension,
ObjectTypeDefinitionNode|InputObjectTypeDefinitionNode|InterfaceTypeDefinitionNode|ScalarTypeDefinitionNode|EnumTypeDefinitionNode|UnionTypeDefinitionNode $definition,
): void
{
): void {
if (static::EXTENSION_TO_DEFINITION_CLASS[$extension::class] !== $definition::class) {
throw new DefinitionException("The type extension {$extension->name->value} of kind {$extension->kind} can not extend a definition of kind {$definition->kind}.");
}
Expand Down
36 changes: 19 additions & 17 deletions src/Schema/Types/Scalars/DateScalar.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,26 +56,28 @@ public function parseLiteral(Node $valueNode, ?array $variables = null): Illumin
protected function tryParsingDate(mixed $value, string $exceptionClass): IlluminateCarbon
{
try {
if (
is_object($value)
if (is_object($value)) {
if ($value::class === IlluminateCarbon::class) {
return $value;
}

// We want to know if we have exactly a Carbon\Carbon, not a subclass thereof
&& (
$value::class === CarbonCarbon::class
if ($value::class === CarbonCarbon::class
|| $value::class === CarbonImmutable::class
)
) {
$carbon = IlluminateCarbon::create(
$value->year,
$value->month,
$value->day,
$value->hour,
$value->minute,
$value->second,
$value->timezone,
);
assert($carbon instanceof IlluminateCarbon, 'Given we had a valid Carbon instance before, this can not fail.');
) {
$carbon = IlluminateCarbon::create(
$value->year,
$value->month,
$value->day,
$value->hour,
$value->minute,
$value->second,
$value->timezone,
);
assert($carbon instanceof IlluminateCarbon, 'Given we had a valid Carbon instance before, this can not fail.');

return $carbon;
return $carbon;
}
}

return $this->parse($value);
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 8 additions & 7 deletions src/Tracing/FederatedTracing/Proto/ContextualizedStats.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/Tracing/FederatedTracing/Proto/FieldStat.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/Tracing/FederatedTracing/Proto/PathErrorStats.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 8 additions & 7 deletions src/Tracing/FederatedTracing/Proto/QueryLatencyStats.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions src/Tracing/FederatedTracing/Proto/Report.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading