-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add addTagsToPost and getPostsByUserName QL endpoints
- Loading branch information
1 parent
c7c035c
commit 7b41b4c
Showing
15 changed files
with
188 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
...phql-querydsl/src/main/java/com/example/graphql/querydsl/model/request/AddTagRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.example.graphql.querydsl.model.request; | ||
|
||
import java.util.List; | ||
|
||
public record AddTagRequest(List<TagRequest> tagNames, Long postId) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 5 additions & 1 deletion
6
...aphql-querydsl/src/main/java/com/example/graphql/querydsl/repositories/TagRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
package com.example.graphql.querydsl.repositories; | ||
|
||
import com.example.graphql.querydsl.entities.Tag; | ||
import java.util.Optional; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.querydsl.QuerydslPredicateExecutor; | ||
|
||
public interface TagRepository extends JpaRepository<Tag, Long>, QuerydslPredicateExecutor<Tag> {} | ||
public interface TagRepository extends JpaRepository<Tag, Long>, QuerydslPredicateExecutor<Tag> { | ||
|
||
Optional<Tag> findByName(String name); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 4 additions & 1 deletion
5
graphql/boot-graphql-querydsl/src/test/java/com/example/graphql/querydsl/utils/TestData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,19 @@ | ||
package com.example.graphql.querydsl.utils; | ||
|
||
import com.example.graphql.querydsl.entities.Post; | ||
import com.example.graphql.querydsl.entities.PostComment; | ||
import com.example.graphql.querydsl.entities.PostDetails; | ||
import java.time.LocalDateTime; | ||
|
||
public final class TestData { | ||
|
||
public static Post getPost(String title, String content) { | ||
public static Post getPost(String title, String content, String review) { | ||
Post post = new Post().setTitle(title).setContent(content); | ||
post.addDetails(new PostDetails() | ||
.setCreatedOn(LocalDateTime.of(2023, 12, 31, 10, 35, 45, 99)) | ||
.setCreatedBy("appUser")); | ||
post.addComment( | ||
new PostComment().setReview(review).setCreatedOn(LocalDateTime.of(2023, 12, 31, 10, 35, 45, 99))); | ||
return post; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
graphql/boot-graphql-querydsl/src/test/resources/graphql-test/addTagsToPosts.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
mutation addTagsToPost($addTagRequest: AddTagRequest!) { | ||
addTagsToPost(addTagRequest: $addTagRequest) { | ||
id | ||
title | ||
content | ||
createdOn | ||
comments { | ||
id | ||
review | ||
createdOn | ||
} | ||
tags { | ||
id | ||
name | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
graphql/boot-graphql-querydsl/src/test/resources/graphql-test/getPostsByUserName.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
query getPostsByUserName($name: String!) { | ||
getPostsByUserName(name: $name) { | ||
id | ||
title | ||
content | ||
comments { | ||
id | ||
review | ||
createdOn | ||
} | ||
tags { | ||
id | ||
name | ||
} | ||
} | ||
} |