Skip to content

Commit ea5207d

Browse files
committed
Changed from mutation->is_mutation interface->is_interface
1 parent b377eb6 commit ea5207d

File tree

6 files changed

+24
-24
lines changed

6 files changed

+24
-24
lines changed

graphene/core/fields.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def resolve(self, instance, args, info):
6060

6161
def get_resolve_fn(self, schema):
6262
object_type = self.get_object_type(schema)
63-
if object_type and object_type._meta.mutation:
63+
if object_type and object_type._meta.is_mutation:
6464
return object_type.mutate
6565
elif self.resolve_fn:
6666
return self.resolve_fn
@@ -109,7 +109,7 @@ def internal_type(self, schema):
109109
def internal_field(self, schema):
110110
if not self.object_type:
111111
raise Exception(
112-
'Field could not be constructed in a non graphene.Type or graphene.Interface')
112+
'Field could not be constructed in a non graphene.ObjectType or graphene.Interface')
113113

114114
extra_args = self.extra_args.copy()
115115
for arg_name, arg_value in self.extra_args.items():
@@ -127,7 +127,7 @@ def internal_field(self, schema):
127127
args = self.args
128128

129129
object_type = self.get_object_type(schema)
130-
if object_type and object_type._meta.mutation:
130+
if object_type and object_type._meta.is_mutation:
131131
assert not self.args, 'Arguments provided for mutations are defined in Input class in Mutation'
132132
args = object_type.input_type.fields_as_arguments(schema)
133133

graphene/core/options.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from graphene.utils import cached_property
22
from collections import OrderedDict, namedtuple
33

4-
DEFAULT_NAMES = ('description', 'name', 'interface', 'mutation',
4+
DEFAULT_NAMES = ('description', 'name', 'is_interface', 'is_mutation',
55
'type_name', 'interfaces', 'proxy')
66

77

@@ -10,8 +10,8 @@ class Options(object):
1010
def __init__(self, meta=None):
1111
self.meta = meta
1212
self.local_fields = []
13-
self.interface = False
14-
self.mutation = False
13+
self.is_interface = False
14+
self.is_mutation = False
1515
self.proxy = False
1616
self.interfaces = []
1717
self.parents = []

graphene/core/types.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,20 @@ def __new__(cls, name, bases, attrs):
4848

4949
new_class.add_to_class('_meta', new_class.options_cls(meta))
5050

51-
new_class._meta.interface = new_class.is_interface(parents)
52-
new_class._meta.mutation = new_class.is_mutation(parents)
51+
new_class._meta.is_interface = new_class.is_interface(parents)
52+
new_class._meta.is_mutation = new_class.is_mutation(parents)
5353

54-
assert not (new_class._meta.interface and new_class._meta.mutation)
54+
assert not (new_class._meta.is_interface and new_class._meta.is_mutation)
5555

5656
input_class = None
57-
if new_class._meta.mutation:
57+
if new_class._meta.is_mutation:
5858
input_class = attrs.pop('Input', None)
5959

6060
# Add all attributes to the class.
6161
for obj_name, obj in attrs.items():
6262
new_class.add_to_class(obj_name, obj)
6363

64-
if new_class._meta.mutation:
64+
if new_class._meta.is_mutation:
6565
assert hasattr(new_class, 'mutate'), "All mutations must implement mutate method"
6666

6767
if input_class:
@@ -103,7 +103,7 @@ def __new__(cls, name, bases, attrs):
103103
new_class.add_to_class(field.field_name, new_field)
104104

105105
new_class._meta.parents.append(base)
106-
if base._meta.interface:
106+
if base._meta.is_interface:
107107
new_class._meta.interfaces.append(base)
108108
# new_class._meta.parents.extend(base._meta.parents)
109109

@@ -129,7 +129,7 @@ def add_to_class(cls, name, value):
129129
class BaseObjectType(object):
130130

131131
def __new__(cls, instance=None, **kwargs):
132-
if cls._meta.interface:
132+
if cls._meta.is_interface:
133133
raise Exception("An interface cannot be initialized")
134134
if instance is None:
135135
if not kwargs:
@@ -173,7 +173,7 @@ def internal_type(cls, schema):
173173
fields_list = cls._meta.fields
174174
fields = lambda: OrderedDict([(f.name, f.internal_field(schema))
175175
for f in fields_list])
176-
if cls._meta.interface:
176+
if cls._meta.is_interface:
177177
return GraphQLInterfaceType(
178178
cls._meta.type_name,
179179
description=cls._meta.description,
@@ -190,13 +190,13 @@ def internal_type(cls, schema):
190190
)
191191

192192

193-
class ObjectType(six.with_metaclass(ObjectTypeMeta, BaseObjectType)):
193+
class Interface(six.with_metaclass(ObjectTypeMeta, BaseObjectType)):
194194
pass
195195

196196

197-
class Mutation(six.with_metaclass(ObjectTypeMeta, BaseObjectType)):
197+
class ObjectType(six.with_metaclass(ObjectTypeMeta, BaseObjectType)):
198198
pass
199199

200200

201-
class Interface(six.with_metaclass(ObjectTypeMeta, BaseObjectType)):
201+
class Mutation(six.with_metaclass(ObjectTypeMeta, BaseObjectType)):
202202
pass

tests/contrib_django/test_types.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ class Meta:
4646

4747

4848
def test_django_interface():
49-
assert DjangoNode._meta.interface is True
49+
assert DjangoNode._meta.is_interface is True
5050

5151

5252
def test_pseudo_interface():
5353
object_type = Character.internal_type(schema)
54-
assert Character._meta.interface is True
54+
assert Character._meta.is_interface is True
5555
assert isinstance(object_type, GraphQLInterfaceType)
5656
assert Character._meta.model == Reporter
5757
assert_equal_lists(
@@ -83,7 +83,7 @@ def test_interface_resolve_type():
8383
def test_object_type():
8484
object_type = Human.internal_type(schema)
8585
fields_map = Human._meta.fields_map
86-
assert Human._meta.interface is False
86+
assert Human._meta.is_interface is False
8787
assert isinstance(object_type, GraphQLObjectType)
8888
assert_equal_lists(
8989
object_type.get_fields().keys(),
@@ -99,5 +99,5 @@ def test_object_type():
9999

100100

101101
def test_node_notinterface():
102-
assert Human._meta.interface is False
102+
assert Human._meta.is_interface is False
103103
assert DjangoNode in Human._meta.interfaces

tests/core/test_options.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111

1212
class Meta:
13-
interface = True
13+
is_interface = True
1414
type_name = 'Character'
1515

1616

tests/core/test_types.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class Meta:
3939

4040
def test_interface():
4141
object_type = Character.internal_type(schema)
42-
assert Character._meta.interface is True
42+
assert Character._meta.is_interface is True
4343
assert isinstance(object_type, GraphQLInterfaceType)
4444
assert Character._meta.type_name == 'core_Character'
4545
assert object_type.description == 'Character description'
@@ -55,7 +55,7 @@ def test_interface_resolve_type():
5555

5656
def test_object_type():
5757
object_type = Human.internal_type(schema)
58-
assert Human._meta.interface is False
58+
assert Human._meta.is_interface is False
5959
assert Human._meta.type_name == 'core_Human'
6060
assert isinstance(object_type, GraphQLObjectType)
6161
assert object_type.description == 'Human description'

0 commit comments

Comments
 (0)