77
88namespace Magento \Framework \GraphQl \Query ;
99
10+ use Magento \Framework \Exception \RuntimeException ;
1011use Magento \Framework \GraphQl \Config \Element \Enum ;
1112use Magento \Framework \GraphQl \ConfigInterface ;
1213use Magento \Framework \GraphQl \Schema \Type \Enum \DataMapperInterface ;
14+ use Magento \Framework \Phrase ;
1315
1416/**
1517 * Processor that looks up definition data of an enum to lookup and convert data as it's specified in the schema.
@@ -27,8 +29,6 @@ class EnumLookup
2729 private $ enumDataMapper ;
2830
2931 /**
30- * EnumLookup constructor.
31- *
3232 * @param ConfigInterface $typeConfig
3333 * @param DataMapperInterface $enumDataMapper
3434 */
@@ -44,11 +44,19 @@ public function __construct(ConfigInterface $typeConfig, DataMapperInterface $en
4444 * @param string $enumName
4545 * @param string $fieldValue
4646 * @return string
47+ * @throws RuntimeException
4748 */
4849 public function getEnumValueFromField (string $ enumName , string $ fieldValue ) : string
4950 {
5051 /** @var Enum $enumObject */
5152 $ enumObject = $ this ->typeConfig ->getConfigElement ($ enumName );
53+
54+ if (!($ enumObject instanceof Enum)) {
55+ throw new RuntimeException (
56+ new Phrase ('Enum type "%1" not defined ' , [$ enumName ])
57+ );
58+ }
59+
5260 $ mappedValues = $ this ->enumDataMapper ->getMappedEnums ($ enumName );
5361
5462 foreach ($ enumObject ->getValues () as $ enumItem ) {
0 commit comments