optionCollection = $optionCollection; $this->valueFactory = $valueFactory; $this->metadataPool = $metadataPool; } /** * Fetch and format configurable variants. * * {@inheritdoc} */ public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null) { $linkField = $this->metadataPool->getMetadata(ProductInterface::class)->getLinkField(); if ($value['type_id'] !== Type::TYPE_CODE || !isset($value[$linkField])) { $result = function () { return null; }; return $this->valueFactory->create($result); } $this->optionCollection->addProductId((int)$value[$linkField]); $result = function () use ($value, $linkField) { return $this->optionCollection->getAttributesByProductId((int)$value[$linkField]); }; return $this->valueFactory->create($result); } }