Skip to content

Commit 8b611ca

Browse files
committed
Rename type names in schema (e.g. s/VoteType/Vote/)
1 parent 84879cf commit 8b611ca

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

hackernews/hackernews/schema.py

+16-16
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,21 @@
33
from graphene_django import DjangoObjectType
44
from django.contrib.auth import get_user_model
55

6-
from links.models import Link
6+
from links.models import Link as LinkModel
77
from links.models import Vote
88

99

10-
class LinkType(DjangoObjectType):
10+
class Link(DjangoObjectType):
1111
class Meta:
12-
model = Link
12+
model = LinkModel
1313

1414

15-
class VoteType(DjangoObjectType):
15+
class Vote(DjangoObjectType):
1616
class Meta:
1717
model = Vote
1818

1919

20-
class UserType(DjangoObjectType):
20+
class User(DjangoObjectType):
2121
class Meta:
2222
model = get_user_model()
2323

@@ -26,7 +26,7 @@ class CreateLink(graphene.Mutation):
2626
id = graphene.Int()
2727
url = graphene.String()
2828
description = graphene.String()
29-
postedBy = graphene.Field(UserType)
29+
postedBy = graphene.Field(User)
3030

3131
class Arguments:
3232
url = graphene.String()
@@ -36,7 +36,7 @@ def mutate(self, info, url, description):
3636
user = info.context.user
3737
if user.is_anonymous:
3838
raise Exception("Anonymous users can't create links!")
39-
link = Link(url=url, description=description, posted_by=user)
39+
link = LinkModel(url=url, description=description, posted_by=user)
4040
link.save()
4141

4242
return CreateLink(
@@ -48,8 +48,8 @@ def mutate(self, info, url, description):
4848

4949

5050
class CreateVote(graphene.Mutation):
51-
user = graphene.Field(UserType)
52-
link = graphene.Field(LinkType)
51+
user = graphene.Field(User)
52+
link = graphene.Field(Link)
5353

5454
class Arguments:
5555
linkId = graphene.Int()
@@ -58,7 +58,7 @@ def mutate(self, info, linkId):
5858
user = info.context.user
5959
if user.is_anonymous:
6060
raise Exception("You must be logged in to vote!")
61-
link = Link.objects.filter(id=linkId).first()
61+
link = LinkModel.objects.filter(id=linkId).first()
6262
if link is None:
6363
raise Exception(f"The link ={linkId} is invalid.")
6464

@@ -68,7 +68,7 @@ def mutate(self, info, linkId):
6868

6969

7070
class CreateUser(graphene.Mutation):
71-
user = graphene.Field(UserType)
71+
user = graphene.Field(User)
7272

7373
class Arguments:
7474
username = graphene.String(required=True)
@@ -96,13 +96,13 @@ class Mutation(graphene.ObjectType):
9696

9797

9898
class Query(graphene.ObjectType):
99-
links = graphene.List(LinkType)
100-
votes = graphene.List(VoteType)
101-
users = graphene.List(UserType)
102-
whoami = graphene.Field(UserType)
99+
links = graphene.List(Link)
100+
votes = graphene.List(Vote)
101+
users = graphene.List(User)
102+
whoami = graphene.Field(User)
103103

104104
def resolve_links(self, info, **kwargs):
105-
return Link.objects.all()
105+
return LinkModel.objects.all()
106106

107107
def resolve_votes(self, info, **kwargs):
108108
return Vote.objects.all()

0 commit comments

Comments
 (0)