Remove AbstractType (#1053)

This commit is contained in:
Jonathan Kim 2019-09-27 09:54:19 +01:00 committed by GitHub
parent e90aa1b712
commit a3b215d891
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 0 additions and 102 deletions

View File

@ -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
}

View File

@ -15,4 +15,3 @@ Types Reference
interfaces
unions
mutations
abstracttypes

View File

@ -1,7 +1,6 @@
from .pyutils.version import get_version
from .types import (
AbstractType,
ObjectType,
InputObjectType,
Interface,
@ -86,6 +85,4 @@ __all__ = [
"lazy_import",
"Context",
"ResolveInfo",
# Deprecated
"AbstractType",
]

View File

@ -20,9 +20,6 @@ from .dynamic import Dynamic
from .union import Union
from .context import Context
# Deprecated
from .abstracttype import AbstractType
__all__ = [
"ObjectType",
@ -52,6 +49,4 @@ __all__ = [
"Union",
"Context",
"ResolveInfo",
# Deprecated
"AbstractType",
]

View File

@ -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)

View File

@ -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]