diff --git a/graphene/types/enum.py b/graphene/types/enum.py index bc61cd4c..ab398f92 100644 --- a/graphene/types/enum.py +++ b/graphene/types/enum.py @@ -9,7 +9,9 @@ def eq_enum(self, other): if isinstance(other, self.__class__): return self is other - return self.value is other + if isinstance(other, PyEnum): + return NotImplemented + return self.value == other def hash_enum(self): diff --git a/graphene/types/tests/test_enum.py b/graphene/types/tests/test_enum.py index e6fce66c..a14e883d 100644 --- a/graphene/types/tests/test_enum.py +++ b/graphene/types/tests/test_enum.py @@ -613,3 +613,15 @@ def resolve_color(_, info): results = schema.execute("query { color }") assert not results.errors assert results.data["color"] == RGB.description.name + + +def test_enum_value_equality(): + class Kind(Enum): + FAVORABLE = "favorable" + UNFAVORABLE = "unfavorable" + + # non-interned string to avoid identity matching + val = "".join(["favor", "able"]) + assert Kind.FAVORABLE == val + assert Kind.FAVORABLE == "favorable" + assert Kind.FAVORABLE != "unfavorable"