GatoGraphQL / GatoGraphQL

Interact with all your data in WordPress using GraphQL

Home Page:https://gatographql.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Validate [5.3.2] Field Selection Merging

leoloso opened this issue · comments

As required by the GraphQL spec: https://spec.graphql.org/draft/#sec-Field-Selection-Merging

It is difficult to implement, as it must happen in MirrorQueryDataStructureFormatter (as decided on runtime, not based on static analysis), and we don't keep a reference to the Field that set the value in the response, as to compare later on that any overriding field (eg: because it has the same alias) is different (here):

$resolvedObjectRet[$leafField->getOutputKey()] = $resolvedObject[$leafField];

Started working on branch Field-Selection-Merging-Validation, but left it unfinished.

Actually it can be implemented, as the list of all the fields to resolved for each object as passed all together as $fields in method addObjectData, so there's no need to keep track of the fields after printing their values, and the validation can be performed in advance.