Skip to content

Commit 6d19823

Browse files
authored
LYNX-194: Do not return region_id and country_id in AttributesForm
1 parent 050034e commit 6d19823

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

app/code/Magento/CustomerGraphQl/Model/Customer/GetAttributesForm.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ public function execute(string $formCode): ?array
4242
{
4343
$attributes = [];
4444
foreach ($this->entity->getAttributes($formCode) as $attribute) {
45+
// region_id and country_id returns large datasets that is also not related between each other and
46+
// not filterable. DirectoryGraphQl contains queries that allow to retrieve this information in a
47+
// meaningful way
48+
if ($attribute->getAttributeCode() === 'region_id' || $attribute->getAttributeCode() === 'country_id') {
49+
continue;
50+
}
4551
$attributes[] = ['entity_type' => $this->type, 'attribute_code' => $attribute->getAttributeCode()];
4652
}
4753
return $attributes;

app/code/Magento/EavGraphQl/etc/schema.graphqls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ type Query {
1111
customAttributeMetadataV2(attributes: [AttributeInput!]): AttributesMetadataOutput! @resolver(class: "Magento\\EavGraphQl\\Model\\Resolver\\AttributesMetadata") @doc(description: "Retrieve EAV attributes metadata.") @cache(cacheIdentity: "Magento\\EavGraphQl\\Model\\Resolver\\Cache\\CustomAttributeMetadataV2Identity")
1212
attributesForm(formCode: String! @doc(description: "Form code.")): AttributesFormOutput!
1313
@resolver(class: "Magento\\EavGraphQl\\Model\\Resolver\\AttributesForm")
14-
@doc(description: "Retrieve EAV attributes associated to a frontend form.")
14+
@doc(description: "Retrieve EAV attributes associated to a frontend form. For region_id and country_id attributes information use DirectoryGraphQl module.")
1515
@cache(cacheIdentity: "Magento\\Eav\\Model\\Cache\\AttributesFormIdentity")
1616
attributesList(
1717
entityType: AttributeEntityTypeEnum! @doc(description: "Entity type.")

dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/Attribute/AttributesFormTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ public function testAttributesForm(): void
8787
}
8888
$this->assertNotContains($attribute2->getAttributeCode(), $item);
8989
$this->assertNotContains($attribute3->getAttributeCode(), $item);
90+
$this->assertNotContains('region_id', $item);
91+
$this->assertNotContains('country_id', $item);
9092
}
9193
$this->fail(sprintf("Attribute '%s' not found in query response", $attribute1->getAttributeCode()));
9294
}

0 commit comments

Comments
 (0)