Skip to content

Commit 64b7065

Browse files
authored
Merge branch 'Clinify-Open-Sauce:main' into main
2 parents 9ed1e8b + 4479c17 commit 64b7065

File tree

4 files changed

+32
-5
lines changed

4 files changed

+32
-5
lines changed

backend/README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,14 @@ mutation deleteMutation{
4343
slug and id is created automatically
4444
```
4545
mutation createMutation {
46-
createPost(postData: {title: "put title here", author: authorID, backgroundlink: "link of the image", category: "put category here"}){
46+
createPost(postData: {title: "put title here", author: authorID, backgroundlink: "link of the image", category: "put category here", content: "put content here"}){
4747
post{
4848
id
4949
title
5050
slug
5151
backgroundlink
5252
category
53+
content
5354
author {
5455
id
5556
name
@@ -65,13 +66,14 @@ mutation createMutation {
6566
n is numeric id
6667
```
6768
mutation updateMutation {
68-
updatePost(postData: {id: n, title: "put updated title here", slug: "put updated slug here", author: authorID, backgroundlink: "updated link of the image", category: "put updated category here"}){
69+
updatePost(postData: {id: n, title: "put updated title here", slug: "put updated slug here", author: authorID, backgroundlink: "updated link of the image", category: "put updated category here", content: "put updated content here"}){
6970
post{
7071
id
7172
title
7273
slug
7374
backgroundlink
7475
category
76+
content
7577
author {
7678
id
7779
name
@@ -103,6 +105,7 @@ query {
103105
title
104106
slug
105107
category
108+
content
106109
author {
107110
id
108111
name
@@ -123,6 +126,7 @@ query {
123126
title
124127
slug
125128
category
129+
content
126130
author {
127131
id
128132
name
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Generated by Django 3.2.4 on 2021-06-26 14:04
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('api', '0001_initial'),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name='post',
15+
name='content',
16+
field=models.TextField(default=''),
17+
preserve_default=False,
18+
),
19+
]

backend/api/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class Post(models.Model):
1515
slug = models.CharField(max_length=1000, unique=True, null=True, blank=True)
1616
category = models.CharField(max_length=100)
1717
author = models.ForeignKey(Author, on_delete=models.CASCADE)
18+
content = models.TextField()
1819

1920
def __str__(self):
2021
return self.title

backend/api/schema.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Query(graphene.ObjectType):
1919
all_posts = graphene.List(PostType)
2020
post = graphene.Field(PostType, post_id=graphene.Int())
2121
all_authors = graphene.List(AuthorType)
22-
author = graphene.Field(AuthorType, author_id_id=graphene.Int())
22+
author = graphene.Field(AuthorType, author_id=graphene.Int())
2323

2424
def resolve_all_posts(self, info, **kwargs):
2525
return Post.objects.all()
@@ -39,6 +39,7 @@ class PostInput(graphene.InputObjectType):
3939
author = graphene.Int()
4040
category = graphene.String()
4141
backgroundlink = graphene.String()
42+
content = graphene.String()
4243

4344
class AuthorInput(graphene.InputObjectType):
4445
id = graphene.ID()
@@ -57,7 +58,8 @@ def mutate(root, info, post_data=None):
5758
title=post_data.title,
5859
author=Author.objects.get(pk=post_data.author),
5960
backgroundlink=post_data.backgroundlink,
60-
category = post_data.category
61+
category = post_data.category,
62+
content = post_data.content
6163
)
6264
post_instance.save()
6365
return CreatePost(post=post_instance)
@@ -93,6 +95,7 @@ def mutate(root, info, post_data=None):
9395
post_instance.author = Author.objects.get(pk=post_data.author)
9496
post_instance.backgroundlink = post_data.backgroundlink
9597
post_instance.category = post_data.category
98+
post_instance.content = post_data.content
9699
post_instance.save()
97100

98101
return UpdatePost(post=post_instance)
@@ -153,4 +156,4 @@ class Mutation(graphene.ObjectType):
153156
delete_author = DeleteAuthor.Field()
154157

155158

156-
schema = graphene.Schema(query=Query, mutation=Mutation)
159+
schema = graphene.Schema(query=Query, mutation=Mutation)

0 commit comments

Comments
 (0)