View BookMutation.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
@Controller | |
@AllArgsConstructor | |
public class BookMutation { | |
BookRepository bookRepository; | |
@MutationMapping | |
public BookOutput newBook(@Argument("input") NewBook newBook){ | |
Book book = Book.builder().authorName(newBook.getAuthorName()).title(newBook.getTitle()).build(); | |
Book book1 = bookRepository.save(book); |
View BookRepository.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
public interface BookRepository extends JpaRepository<Book, Long> { | |
Book findBookByTitle(String title); | |
} |
View BookQuery.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
@Controller | |
@AllArgsConstructor | |
public class BookQuery{ | |
private final BookRepository bookRepository; | |
@QueryMapping | |
public Iterable<Book> allBook(){ | |
return bookRepository.findAll(); | |
} |
View query.graphqls
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
type Query { | |
allBook: [Book] | |
getBookByTitle(filter: BookInput): Book | |
} | |
type Mutation { | |
newBook(input: NewBook): BookOutput | |
deleteBook(input:BookInput): BookOutput | |
} |
View book.graphqls
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
type Book { | |
id: Int | |
title: String | |
authorName: String | |
} | |
input BookInput { | |
id: Int | |
title: String | |
authorName: String |
View BookInput.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
@Getter | |
@Setter | |
@Builder | |
public class BookInput { | |
private Long id; | |
private String title; | |
private String authorName; | |
} |
View Book.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
@Getter | |
@Setter | |
@RequiredArgsConstructor | |
@AllArgsConstructor | |
@Builder | |
@Entity | |
@Table(name = "Book") | |
public class Book { | |
@Id |
View pom.xml
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
<dependency> | |
<groupId>org.springframework.boot</groupId> | |
<artifactId>spring-boot-starter-data-couchbase</artifactId> | |
</dependency> | |
<dependency> | |
<groupId>org.springframework.boot</groupId> | |
<artifactId>spring-boot-starter-web</artifactId> | |
</dependency> | |
<dependency> | |
<groupId>org.projectlombok</groupId> |
View Book.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
@Builder | |
@Data | |
@AllArgsConstructor | |
@Document | |
public class Book { | |
@Id | |
private final String id; | |
@Field |
View CouchbaseConfig.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
@Configuration | |
public class CouchbaseConfig extends AbstractCouchbaseConfiguration { | |
@Override | |
public String getConnectionString() { | |
return "127.0.0.1"; | |
} | |
@Override | |
public String getUserName() { |
NewerOlder