mapper = $mapper; $this->typeLocator = $typeLocator; $this->collection = $collection; } /** * Read configuration scope * * @param string|null $scope * @return array * @throws GraphQlInputException * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function read($scope = null) : array { $typeNames = $this->mapper->getMappedTypes(\Magento\Catalog\Model\Product::ENTITY); $config =[]; /** @var \Magento\Catalog\Model\ResourceModel\Eav\Attribute $attribute */ foreach ($this->collection->getAttributes() as $attribute) { $attributeCode = $attribute->getAttributeCode(); $locatedType = $this->typeLocator->getType( $attributeCode, \Magento\Catalog\Model\Product::ENTITY ) ?: 'String'; $locatedType = $locatedType === TypeProcessor::NORMALIZED_ANY_TYPE ? 'String' : ucfirst($locatedType); foreach ($typeNames as $typeName) { $config[$typeName]['fields'][$attributeCode] = [ 'name' => $attributeCode, 'type' => $locatedType, 'arguments' => [] ]; } } return $config; } }