Skip to content

Instantly share code, notes, and snippets.

Avatar

Ibrahim Ates atesibrahim

View GitHub Profile
View BookMutation.java
@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
public interface BookRepository extends JpaRepository<Book, Long> {
Book findBookByTitle(String title);
}
View BookQuery.java
@Controller
@AllArgsConstructor
public class BookQuery{
private final BookRepository bookRepository;
@QueryMapping
public Iterable<Book> allBook(){
return bookRepository.findAll();
}
View query.graphqls
type Query {
allBook: [Book]
getBookByTitle(filter: BookInput): Book
}
type Mutation {
newBook(input: NewBook): BookOutput
deleteBook(input:BookInput): BookOutput
}
View book.graphqls
type Book {
id: Int
title: String
authorName: String
}
input BookInput {
id: Int
title: String
authorName: String
View BookInput.java
@Getter
@Setter
@Builder
public class BookInput {
private Long id;
private String title;
private String authorName;
}
View Book.java
@Getter
@Setter
@RequiredArgsConstructor
@AllArgsConstructor
@Builder
@Entity
@Table(name = "Book")
public class Book {
@Id
@atesibrahim
atesibrahim / pom.xml
Created Jul 19, 2022
Couchbase Example
View pom.xml
<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>
@atesibrahim
atesibrahim / Book.java
Created Jul 19, 2022
Coucbase Example
View Book.java
@Builder
@Data
@AllArgsConstructor
@Document
public class Book {
@Id
private final String id;
@Field
View CouchbaseConfig.java
@Configuration
public class CouchbaseConfig extends AbstractCouchbaseConfiguration {
@Override
public String getConnectionString() {
return "127.0.0.1";
}
@Override
public String getUserName() {