Skip to content

Commit 52ad28c

Browse files
committed
[add]: ability to query for likes
1 parent ec8b2d6 commit 52ad28c

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

app/books/schema.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,19 @@ class BookType(DjangoObjectType):
88
class Meta:
99
model = Book
1010

11+
class LikeType(DjangoObjectType):
12+
class Meta:
13+
model = Like
14+
1115

1216
class Query(graphene.ObjectType):
1317
books = graphene.List(BookType)
18+
likes = graphene.List(LikeType)
1419

1520
def resolve_books(self, info):
1621
return Book.objects.all()
22+
def resolve_likes(self, info):
23+
return Like.objects.all()
1724

1825

1926
class CreateBook(graphene.Mutation):
@@ -41,10 +48,10 @@ class UpdateBook(graphene.Mutation):
4148

4249
class Arguments:
4350
book_id = graphene.Int(required=True)
44-
title = graphene.String(required=False)
45-
author = graphene.String(required=False)
46-
description = graphene.String(required=False)
47-
url = graphene.String(required=False)
51+
title = graphene.String()
52+
author = graphene.String()
53+
description = graphene.String()
54+
url = graphene.String()
4855

4956
def mutate(self, info, book_id, title, author, description, url):
5057
user = info.context.user

0 commit comments

Comments
 (0)