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

Preserve extended methods from class-based types in SchemaExtender::extend() #934

Merged
merged 13 commits into from
Sep 10, 2021
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ You can find and compare releases at the [GitHub release page](https://github.co
- Handle `null` parent of list in `ValuesOfCorrectType::getVisitor`
- Allow sending both `query` and `queryId`, ignore `queryId` in that case
- Fix `extend()` to preserve `repeatable` (#931)
- Preserve extended methods from class-based types in `SchemaExtender::extend()`

### Removed

Expand Down
2 changes: 1 addition & 1 deletion UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ Starting from v0.7.0 the signature has changed to (note the new `$context` argum
/**
* @param mixed $object The parent resolved object
* @param array $args Input arguments
* @param mixed $context The context object hat was passed to GraphQL::execute
* @param mixed $context The context object that was passed to GraphQL::execute
* @param ResolveInfo $info ResolveInfo object
* @return mixed
*/
Expand Down
9 changes: 7 additions & 2 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ parameters:
path: src/Language/AST/Node.php

-
message: "#^Variable property access on GraphQL\\\\Language\\\\AST\\\\Node\\|null\\.$#"
message: "#^Variable property access on GraphQL\\\\Language\\\\AST\\\\Node\\.$#"
count: 1
path: src/Language/Visitor.php

-
message: "#^Variable property access on GraphQL\\\\Language\\\\AST\\\\Node\\.$#"
message: "#^Variable property access on GraphQL\\\\Language\\\\AST\\\\Node\\|null\\.$#"
count: 1
path: src/Language/Visitor.php

Expand All @@ -80,6 +80,11 @@ parameters:
count: 2
path: src/Utils/AST.php

-
message: "#^Method GraphQL\\\\Utils\\\\SchemaExtender\\:\\:extendType\\(\\) should return GraphQL\\\\Type\\\\Definition\\\\ListOfType\\|\\(GraphQL\\\\Type\\\\Definition\\\\NamedType&GraphQL\\\\Type\\\\Definition\\\\Type\\)\\|GraphQL\\\\Type\\\\Definition\\\\NonNull but returns GraphQL\\\\Type\\\\Definition\\\\Type\\.$#"
count: 1
path: src/Utils/SchemaExtender.php

-
message: "#^Variable property access on object\\.$#"
count: 1
Expand Down
8 changes: 4 additions & 4 deletions src/Type/Definition/AbstractType.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
interface AbstractType
{
/**
* Resolves concrete ObjectType for given object value
* Resolves the concrete ObjectType for the given value.
*
* @param object $objectValue
* @param mixed[] $context
* @param mixed $objectValue The resolved value for the object type
* @param mixed $context The context that was passed to GraphQL::execute()
*
* @return mixed
* @return ObjectType|callable(): ObjectType|null
*/
public function resolveType($objectValue, $context, ResolveInfo $info);
}
8 changes: 0 additions & 8 deletions src/Type/Definition/InterfaceType.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,6 @@ public function getInterfaces(): array
return $this->interfaces;
}

/**
* Resolves concrete ObjectType for given object value
*
* @param object $objectValue
* @param mixed $context
*
* @return Type|mixed|null
*/
public function resolveType($objectValue, $context, ResolveInfo $info)
{
if (isset($this->config['resolveType'])) {
Expand Down
8 changes: 4 additions & 4 deletions src/Type/Definition/ObjectType.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,16 +161,16 @@ public function getInterfaces(): array
}

/**
* @param mixed $value
* @param mixed $context
* @param mixed $objectValue The resolved value for the object type
* @param mixed $context The context that was passed to GraphQL::execute()
*
* @return bool|Deferred|null
*/
public function isTypeOf($value, $context, ResolveInfo $info)
public function isTypeOf($objectValue, $context, ResolveInfo $info)
{
return isset($this->config['isTypeOf'])
? $this->config['isTypeOf'](
$value,
$objectValue,
$context,
$info
)
Expand Down
8 changes: 0 additions & 8 deletions src/Type/Definition/UnionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,6 @@ public function getTypes(): array
return $this->types;
}

/**
* Resolves concrete ObjectType for given object value
*
* @param object $objectValue
* @param mixed $context
*
* @return callable|mixed|null
*/
public function resolveType($objectValue, $context, ResolveInfo $info)
{
if (isset($this->config['resolveType'])) {
Expand Down
Loading