From 022748cc0f094bcff5345d2252aff3a1221fa95b Mon Sep 17 00:00:00 2001 From: Jonathan Kim Date: Tue, 9 Jul 2019 13:47:35 +0100 Subject: [PATCH] Start raising PendingDeprecationWarnings for using only_fields and exclude_fields --- graphene_django/types.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/graphene_django/types.py b/graphene_django/types.py index 855761c..ec426f1 100644 --- a/graphene_django/types.py +++ b/graphene_django/types.py @@ -1,3 +1,4 @@ +import warnings from collections import OrderedDict import six @@ -123,6 +124,11 @@ class DjangoObjectType(ObjectType): if only_fields and fields: raise Exception("Can't set both only_fields and fields") if only_fields: + warnings.warn( + "Defining `only_fields` is deprecated in favour of `fields`.", + PendingDeprecationWarning, + stacklevel=2, + ) fields = only_fields if fields and fields != ALL_FIELDS and not isinstance(fields, (list, tuple)): raise TypeError( @@ -137,6 +143,11 @@ class DjangoObjectType(ObjectType): if exclude_fields and exclude: raise Exception("Can't set both exclude_fields and exclude") if exclude_fields: + warnings.warn( + "Defining `exclude_fields` is deprecated in favour of `exclude`.", + PendingDeprecationWarning, + stacklevel=2, + ) exclude = exclude_fields if exclude and not isinstance(exclude, (list, tuple)): raise TypeError(