Skip to content

Commit bf168e7

Browse files
committed
Use new syntax for fields and arguments
1 parent a2ab008 commit bf168e7

File tree

17 files changed

+78
-80
lines changed

17 files changed

+78
-80
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ Here is one example for get you started:
2828

2929
```python
3030
class Query(graphene.ObjectType):
31-
hello = graphene.StringField(description='A typical hello world')
32-
ping = graphene.StringField(description='Ping someone',
33-
to=graphene.Argument(graphene.String))
31+
hello = graphene.String(description='A typical hello world')
32+
ping = graphene.String(description='Ping someone',
33+
to=graphene.String())
3434

3535
def resolve_hello(self, args, info):
3636
return 'World'

README.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ Here is one example for get you started:
3535
.. code:: python
3636
3737
class Query(graphene.ObjectType):
38-
hello = graphene.StringField(description='A typical hello world')
39-
ping = graphene.StringField(description='Ping someone',
40-
to=graphene.Argument(graphene.String))
38+
hello = graphene.String(description='A typical hello world')
39+
ping = graphene.String(description='Ping someone',
40+
to=graphene.String())
4141
4242
def resolve_hello(self, args, info):
4343
return 'World'

examples/starwars/schema.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,33 +12,33 @@
1212

1313

1414
class Character(graphene.Interface):
15-
id = graphene.IDField()
16-
name = graphene.StringField()
17-
friends = graphene.ListField('Character')
18-
appears_in = graphene.ListField(Episode)
15+
id = graphene.ID()
16+
name = graphene.String()
17+
friends = graphene.List('Character')
18+
appears_in = graphene.List(Episode)
1919

2020
def resolve_friends(self, args, *_):
2121
# The character friends is a list of strings
2222
return [get_character(f) for f in self.friends]
2323

2424

2525
class Human(Character):
26-
home_planet = graphene.StringField()
26+
home_planet = graphene.String()
2727

2828

2929
class Droid(Character):
30-
primary_function = graphene.StringField()
30+
primary_function = graphene.String()
3131

3232

3333
class Query(graphene.ObjectType):
3434
hero = graphene.Field(Character,
3535
episode=graphene.Argument(Episode)
3636
)
3737
human = graphene.Field(Human,
38-
id=graphene.Argument(graphene.String)
38+
id=graphene.String()
3939
)
4040
droid = graphene.Field(Droid,
41-
id=graphene.Argument(graphene.String)
41+
id=graphene.String()
4242
)
4343

4444
@resolve_only_args

examples/starwars_django/schema.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ def get_node(cls, id):
4040
class IntroduceShip(relay.ClientIDMutation):
4141

4242
class Input:
43-
ship_name = graphene.StringField(required=True)
44-
faction_id = graphene.StringField(required=True)
43+
ship_name = graphene.String(required=True)
44+
faction_id = graphene.String(required=True)
4545

4646
ship = graphene.Field(Ship)
4747
faction = graphene.Field(Faction)

examples/starwars_relay/schema.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
class Ship(relay.Node):
1010
'''A ship in the Star Wars saga'''
11-
name = graphene.StringField(description='The name of the ship.')
11+
name = graphene.String(description='The name of the ship.')
1212

1313
@classmethod
1414
def get_node(cls, id):
@@ -17,7 +17,7 @@ def get_node(cls, id):
1717

1818
class Faction(relay.Node):
1919
'''A faction in the Star Wars saga'''
20-
name = graphene.StringField(description='The name of the faction.')
20+
name = graphene.String(description='The name of the faction.')
2121
ships = relay.ConnectionField(
2222
Ship, description='The ships used by the faction.')
2323

@@ -34,8 +34,8 @@ def get_node(cls, id):
3434
class IntroduceShip(relay.ClientIDMutation):
3535

3636
class Input:
37-
ship_name = graphene.StringField(required=True)
38-
faction_id = graphene.StringField(required=True)
37+
ship_name = graphene.String(required=True)
38+
faction_id = graphene.String(required=True)
3939

4040
ship = graphene.Field(Ship)
4141
faction = graphene.Field(Faction)

graphene/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
from graphene.core.types import (
1212
ObjectType,
13+
InputObjectType,
1314
Interface,
1415
Mutation,
1516
BaseType,
@@ -55,6 +56,7 @@
5556
'BaseType',
5657
'LazyType',
5758
'ObjectType',
59+
'InputObjectType',
5860
'Interface',
5961
'Mutation',
6062
'Field',

graphene/contrib/django/tests/test_types.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from graphene import Schema
44
from graphene.contrib.django.types import DjangoInterface, DjangoNode
5-
from graphene.core.fields import Field, IntField
5+
from graphene.core.fields import Field
66
from graphene.core.types.scalars import Int
77
from graphene.relay.fields import GlobalIDField
88
from graphql.core.type import GraphQLInterfaceType, GraphQLObjectType
@@ -23,7 +23,7 @@ class Meta:
2323
class Human(DjangoNode):
2424
'''Human description'''
2525

26-
pub_date = IntField()
26+
pub_date = Int()
2727

2828
def get_node(self, id):
2929
pass

graphene/contrib/django/tests/test_urls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def get_node(self, id):
1818

1919

2020
class Human(DjangoNode):
21-
raises = graphene.StringField()
21+
raises = graphene.String()
2222

2323
class Meta:
2424
model = Article

graphene/core/tests/test_mutations.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55

66

77
class Query(graphene.ObjectType):
8-
base = graphene.StringField()
8+
base = graphene.String()
99

1010

1111
class ChangeNumber(graphene.Mutation):
1212
'''Result mutation'''
1313
class Input:
14-
to = graphene.IntField()
14+
to = graphene.Int()
1515

16-
result = graphene.StringField()
16+
result = graphene.String()
1717

1818
@classmethod
1919
def mutate(cls, instance, args, info):

graphene/core/tests/test_options.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from py.test import raises
22

3-
from graphene.core.fields import StringField
3+
from graphene.core.fields import Field
44
from graphene.core.options import Options
55

66

@@ -20,7 +20,7 @@ class ObjectType(object):
2020
pass
2121

2222
opt.contribute_to_class(ObjectType, '_meta')
23-
f = StringField()
23+
f = Field(None)
2424
f.attname = 'string_field'
2525
opt.add_field(f)
2626
assert f in opt.fields

0 commit comments

Comments
 (0)