diff --git a/docs/types/abstracttypes.rst b/docs/types/abstracttypes.rst deleted file mode 100644 index 093cfd931..000000000 --- a/docs/types/abstracttypes.rst +++ /dev/null @@ -1,43 +0,0 @@ -AbstractTypes -============= - -An AbstractType contains fields that can be shared among -``graphene.ObjectType``, ``graphene.Interface``, -``graphene.InputObjectType`` or other ``graphene.AbstractType``. - -The basics: - -- Each AbstractType is a Python class that inherits from ``graphene.AbstractType``. -- Each attribute of the AbstractType represents a field (a ``graphene.Field`` or - ``graphene.InputField`` depending on where it is mounted) - -Quick example -------------- - -In this example UserFields is an ``AbstractType`` with a name. ``User`` and -``UserInput`` are two types that have their own fields -plus the ones defined in ``UserFields``. - -.. code:: python - - import graphene - - class UserFields(graphene.AbstractType): - name = graphene.String() - - class User(graphene.ObjectType, UserFields): - pass - - class UserInput(graphene.InputObjectType, UserFields): - pass - - -.. code:: - - type User { - name: String - } - - inputtype UserInput { - name: String - } diff --git a/docs/types/index.rst b/docs/types/index.rst index acbdb8e81..51f6464cc 100644 --- a/docs/types/index.rst +++ b/docs/types/index.rst @@ -13,4 +13,3 @@ Types Reference unions schema mutations - abstracttypes diff --git a/graphene/__init__.py b/graphene/__init__.py index 24a90a1bb..2efd9e021 100644 --- a/graphene/__init__.py +++ b/graphene/__init__.py @@ -1,7 +1,6 @@ from .pyutils.version import get_version from .types import ( - AbstractType, ObjectType, InputObjectType, Interface, @@ -85,6 +84,4 @@ "lazy_import", "Context", "ResolveInfo", - # Deprecated - "AbstractType", ] diff --git a/graphene/types/__init__.py b/graphene/types/__init__.py index 292db235b..680149a35 100644 --- a/graphene/types/__init__.py +++ b/graphene/types/__init__.py @@ -20,9 +20,6 @@ from .union import Union from .context import Context -# Deprecated -from .abstracttype import AbstractType - __all__ = [ "ObjectType", @@ -52,6 +49,4 @@ "Union", "Context", "ResolveInfo", - # Deprecated - "AbstractType", ] diff --git a/graphene/types/abstracttype.py b/graphene/types/abstracttype.py deleted file mode 100644 index 4eeb7f9cb..000000000 --- a/graphene/types/abstracttype.py +++ /dev/null @@ -1,11 +0,0 @@ -from ..utils.deprecated import warn_deprecation -from ..utils.subclass_with_meta import SubclassWithMeta - - -class AbstractType(SubclassWithMeta): - def __init_subclass__(cls, *args, **kwargs): - warn_deprecation( - "Abstract type is deprecated, please use normal object inheritance instead.\n" - "See more: https://github.com/graphql-python/graphene/blob/master/UPGRADE-v2.0.md#deprecations" - ) - super(AbstractType, cls).__init_subclass__(*args, **kwargs) diff --git a/graphene/types/tests/test_abstracttype.py b/graphene/types/tests/test_abstracttype.py deleted file mode 100644 index a50c87571..000000000 --- a/graphene/types/tests/test_abstracttype.py +++ /dev/null @@ -1,39 +0,0 @@ -from pytest import deprecated_call - -from ..abstracttype import AbstractType -from ..field import Field -from ..objecttype import ObjectType -from ..unmountedtype import UnmountedType - - -class MyType(ObjectType): - pass - - -class MyScalar(UnmountedType): - def get_type(self): - return MyType - - -def test_abstract_objecttype_warn_deprecation(): - with deprecated_call(): - - # noinspection PyUnusedLocal - class MyAbstractType(AbstractType): - field1 = MyScalar() - - -def test_generate_objecttype_inherit_abstracttype(): - with deprecated_call(): - - class MyAbstractType(AbstractType): - field1 = MyScalar() - - class MyObjectType(ObjectType, MyAbstractType): - field2 = MyScalar() - - assert MyObjectType._meta.description is None - assert MyObjectType._meta.interfaces == () - assert MyObjectType._meta.name == "MyObjectType" - assert list(MyObjectType._meta.fields) == ["field1", "field2"] - assert list(map(type, MyObjectType._meta.fields.values())) == [Field, Field]