add queryplan#436
Conversation
515ba09 to
7b787b5
Compare
| self::assertEquals($expectedReferencedFields, $queryPlan->referencedFields()); | ||
| self::assertEquals(['url', 'width', 'height'], $queryPlan->subFields('Image')); | ||
|
|
||
| static::assertTrue($queryPlan->hasField('url')); |
There was a problem hiding this comment.
What's up with the self:: vs. static:: calls here?
Maybe it's through out the codebase and I just didn't notice it before 🤔
There was a problem hiding this comment.
good catch 👍
the convention seems to be self:: but i'm used to static::
fixed it
85bdb8b to
3e8d848
Compare
| * @param mixed[] $variableValues | ||
| * @param FragmentDefinitionNode[] $fragments | ||
| * | ||
| * @throws Error |
There was a problem hiding this comment.
IMO the @throws anotation can be dropped. I have never found a way how to sustainably maintain those across the whole project.
|
|
||
| public function hasType(string $type) : bool | ||
| { | ||
| return count(array_filter($this->referencedTypes(), static function ($element) use ($type) { |
There was a problem hiding this comment.
I guess we can typehint string $element. And then change variable name to $referencedType
| /** | ||
| * @return string[] | ||
| */ | ||
| public function referencedTypes() : array |
| /** | ||
| * @return string[] | ||
| */ | ||
| public function referencedFields() : array |
|
|
||
| public function hasField(string $field) : bool | ||
| { | ||
| return count(array_filter($this->referencedFields(), static function ($element) use ($field) { |
There was a problem hiding this comment.
| return count(array_filter($this->referencedFields(), static function ($element) use ($field) { | |
| return count(array_filter($this->referencedFields(), static function (string $referencedField) use ($field) { |
| } elseif ($selectionNode instanceof FragmentSpreadNode) { | ||
| $spreadName = $selectionNode->name->value; | ||
| if (isset($this->fragments[$spreadName])) { | ||
| /** @var FragmentDefinitionNode $fragment */ |
| public $variableValues = []; | ||
|
|
||
| /** | ||
| * @internal |
There was a problem hiding this comment.
the var is private so I guess we can drop this
| * | ||
| * @var QueryPlan | ||
| */ | ||
| private $queryPlan = null; |
There was a problem hiding this comment.
null is default, can be dropped
| return $fields; | ||
| } | ||
|
|
||
| public function lookahead() : QueryPlan |
There was a problem hiding this comment.
If meant as verb, the proper camel case is lookAhead
| use GraphQL\Type\Schema; | ||
| use PHPUnit\Framework\TestCase; | ||
|
|
||
| class QueryPlanTest extends TestCase |
There was a problem hiding this comment.
| class QueryPlanTest extends TestCase | |
| final class QueryPlanTest extends TestCase |
3e8d848 to
5b3f44c
Compare
|
This is great! I need some time to digest it before I can post any feedback or merge. Thanks! |
| ], | ||
| array_keys((array) $info) | ||
| ); | ||
|
|
There was a problem hiding this comment.
Why deleting this? Can't you just add queryPlan key to this list?
There was a problem hiding this comment.
queryPlan is declared private because it should only be loaded lazy when you call lookAhead()
When you cast the resolveInfo to array now it cpontains some binary string instead of queryPlan because it is private.
Furthermore i really saw no value added by this test, because every key mentionied there would be used for own assertions, so the test will fail anyway if you remove one of the public properties.
There was a problem hiding this comment.
Sorry, missed your reply. Makes sense.
Provide the possibility to lookahead the Query Execution.
This one adds the API proposed in #65.
From #65: