Skip to content

Commit

Permalink
Preserve extended methods from class-based types in `SchemaExtender::…
Browse files Browse the repository at this point in the history
…extend()` (#934)
  • Loading branch information
abdullahseba committed Sep 10, 2021
1 parent 2abac8c commit b85f8a0
Show file tree
Hide file tree
Showing 14 changed files with 424 additions and 182 deletions.
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

0 comments on commit b85f8a0

Please sign in to comment.