-
Notifications
You must be signed in to change notification settings - Fork 154
GraphQl-93: Implement support for variables in query #259
Conversation
-- Variables may be Input type -- Query now accepts variables -- added type property for Output/Input Type element -- functional test was added
Request Sample:
With variables:
|
|
||
$query | ||
= <<<'QUERY' | ||
query GetProductsQuery($page: Int, $filterInput: ProductFilterInput){ |
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.
Do we have enum used here?
* | ||
* @return string[] | ||
* @return array $types | ||
* name string |
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.
Is this common style for documenting array structure? Usually I see
['name' => 'example value', 'type' = 'example value']
* @return string[] | ||
* @return array $types | ||
* name string | ||
* type string | ||
*/ | ||
public function getDeclaredTypeNames() : array |
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.
Can we rename this method, to getDeclaredTypes
, for example
} | ||
|
||
/** | ||
* Create type object based off array of configured GraphQL InputType data. |
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.
* Create type object based off array of configured GraphQL InputType data. | |
* Create input type object based off array of configured GraphQL InputType data. |
@@ -8,7 +8,7 @@ | |||
namespace Magento\Framework\GraphQl\Config\Element; | |||
|
|||
/** | |||
* Describes all the configured data of an Output or Input type in GraphQL. | |||
* Class representing 'type' GraphQL config element. |
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.
* Class representing 'type' GraphQL config element. | |
* Class representing 'type' GraphQL config elements. |
* | ||
* @return string[] | ||
*/ | ||
private function getVariables(array $variables): array |
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.
private function getVariables(array $variables): array | |
private function formatVariables(array $variables): array |
or maybe extractVariables
$typesImplementors = []; | ||
foreach ($this->config->getDeclaredTypeNames() as $name) { | ||
$typesImplementors [] = $this->outputMapper->getOutputType($name); | ||
foreach ($this->config->getDeclaredTypeNames() as $type) { |
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.
Please create a ticket not to load all types, but just the ones which do not have references from Query/Mutation types
$configElementClass = get_class($configElement); | ||
if (!isset($this->configToTypeMap[$configElementClass])) { | ||
throw new GraphQlInputException( | ||
new Phrase("Type for '{$configElementClass}' has not declared.") |
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.
new Phrase("Type for '{$configElementClass}' has not declared.") | |
new Phrase("No mapping to Webonyx type is declared for '{$configElementClass}' config element type.") |
-- Fixes after CR
-- Fixes after CR
-- Builds fixes
Hi @Aquarvin, thank you for your contribution! |
-- Variables may be Input type
-- Query now accepts variables
-- added type property for Output/Input Type element
-- functional test was added
Description (*)
Currently running the following Graph Ql query
with variables:
Will return filtered products list, since ProductFilterInput is an input type, according to scheme
Fixed Issues (if relevant)
Manual testing scenarios (*)
Contribution checklist (*)