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); |
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); | |
} |
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(); | |
} |
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 | |
} |
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 |
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; | |
} |
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 |
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> |
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 |
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