From d933e04b04075a296a65ff51e9b0d17d552f35dd Mon Sep 17 00:00:00 2001 From: Jonathan Kim Date: Sat, 27 Jun 2020 14:21:24 +0100 Subject: [PATCH] Add get_underlying_type function --- graphene/types/utils.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/graphene/types/utils.py b/graphene/types/utils.py index 3b195d69..1976448a 100644 --- a/graphene/types/utils.py +++ b/graphene/types/utils.py @@ -41,3 +41,10 @@ def get_type(_type): if inspect.isfunction(_type) or isinstance(_type, partial): return _type() return _type + + +def get_underlying_type(_type): + """Get the underlying type even if it is wrapped in structures like NonNull""" + while hasattr(_type, "of_type"): + _type = _type.of_type + return _type