-
Notifications
You must be signed in to change notification settings - Fork 97
Support aliases for selection set and arguments for scalar selected fields. #15
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
Conversation
Add the ability to set arguments for scalar selected fields. fix: pass tests on windows PHP_EOL.
@actionm Two comments on the design here:
|
@actionm Actually, I was wrong on point (1), your change will not break backward-compatibility. We just need to discuss point (2). I'm going over the code in details now as well. |
|
||
if (is_array($arguments) && count($arguments)) { | ||
|
||
$params = ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@actionm We already have a method that converts an arguments array into a string representation, we should figure out how to re-use it here rather than duplicate it. It's in the Query
class.
if (is_array($arguments) && count($arguments)) { | ||
|
||
$params = ''; | ||
foreach ($arguments as $k => $v) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@actionm Another instance of code duplication for the same functionality.
); | ||
|
||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@actionm We need tests for sub-selections (nested queries) with arguments/aliases.
(string) $builder->getQuery() | ||
); | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@actionm We need a test to cover the case of usage of arguments without aliases.
@@ -22,14 +22,35 @@ trait FieldTrait | |||
public function setSelectionSet(array $selectionSet) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@actionm I kind of don't understand why this change is necessary? 🤔
Is it because you want to add the feature of selecting fields with aliases and arguments through the Query
class? It's not required for selecting one field through the AbstractQueryBuilder
as it converts all selected fields into string before the selection set is set in the query class. Or maybe I'm missing something here.
@actionm My suggestion to overcoming the nested |
mghoneimy/php-graphql-oqm#1 (comment)
The ability to set arguments for scalar selected fields.
Example:
Support aliases and arguments for selection set.
Example:
fix: pass tests on windows PHP_EOL.