Skip to content

Commit 0985244

Browse files
committed
GraphQl-93: Implement support for variables in query
-- Fixes after CR
1 parent 6f585f4 commit 0985244

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

lib/internal/Magento/Framework/GraphQl/Config.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@ public function getConfigElement(string $configElementName) : ConfigElementInter
8383
/**
8484
* Return all type names declared in a GraphQL schema's configuration and their type.
8585
*
86+
* Format is ['name' => 'example value', 'type' = 'example value']
87+
*
8688
* @return array $types
87-
* name string
88-
* type string
8989
*/
90-
public function getDeclaredTypeNames() : array
90+
public function getDeclaredTypes() : array
9191
{
9292
$types = [];
9393
foreach ($this->configData->get(null) as $item) {

lib/internal/Magento/Framework/GraphQl/Config/Element/InputFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function createFromConfigData(array $data): ConfigElementInterface
7373
}
7474

7575
/**
76-
* Create type object based off array of configured GraphQL InputType data.
76+
* Create input type object based off array of configured GraphQL InputType data.
7777
*
7878
* Type data must contain name and the type's fields. Optional data includes description.
7979
*

lib/internal/Magento/Framework/GraphQl/Query/Fields.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function setQuery($query, array $variables = null)
4444
]
4545
);
4646
if (isset($variables)) {
47-
$queryFields = array_merge($queryFields, $this->getVariables($variables));
47+
$queryFields = array_merge($queryFields, $this->extracttVariables($variables));
4848
}
4949
} catch (\Exception $e) {
5050
// If a syntax error is encountered do not collect fields
@@ -75,12 +75,12 @@ public function getFieldsUsedInQuery()
7575
*
7676
* @return string[]
7777
*/
78-
private function getVariables(array $variables): array
78+
private function extracttVariables(array $variables): array
7979
{
8080
$fields = [];
8181
foreach ($variables as $key => $value){
8282
if (is_array($value)){
83-
$fields = array_merge($fields, $this->getVariables($value));
83+
$fields = array_merge($fields, $this->extracttVariables($value));
8484
}
8585
$fields[$key] = $key;
8686
}

lib/internal/Magento/Framework/GraphQl/Schema/Type/TypeRegistry.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ public function get(string $typeName): TypeInterface
7171
$configElementClass = get_class($configElement);
7272
if (!isset($this->configToTypeMap[$configElementClass])) {
7373
throw new GraphQlInputException(
74-
new Phrase("Type for '{$configElementClass}' has not declared.")
74+
new Phrase(
75+
"No mapping to Webonyx type is declared for '%1' config element type.",
76+
[$configElementClass]
77+
)
7578
);
7679
}
7780

0 commit comments

Comments
 (0)