Skip to content

Instantly share code, notes, and snippets.

View ridhoperdana's full-sized avatar
🎯
Focusing

Ridho Perdana ridhoperdana

🎯
Focusing
View GitHub Profile
@ridhoperdana
ridhoperdana / operation.go
Created June 12, 2019 03:17
Simple code which implement method for add number and minus number.
package calculator
import "context"
type operation struct {
SavedNumber int
}
// Add is method implementation to add number with saved number
func (s *operation) Add(ctx context.Context, number int) (int, error) {
@ridhoperdana
ridhoperdana / operation_test.go
Created June 12, 2019 03:21
Testfile for operation.go
package calculator_test
import (
"context"
"testing"
"github.com/ridhoperdana/calculator"
)
func TestSempoa_Add(t *testing.T) {
@ridhoperdana
ridhoperdana / main.go
Created June 12, 2019 03:25
main file to run operator.go with add function 10 value
package main
import (
"context"
"fmt"
"github.com/ridhoperdana/calculator"
)
func main() {
BINARY=crawler
# Installing dependency
.PHONY: vendor
go mod vendor
# Linter
.PHONY: vendor lint-prepare
lint-prepare:
@echo "Installing golangci-lint"
package models
import (
"time"
)
// Article represent the article model
type Article struct {
ID int64 `json:"id"`
Title string `json:"title" validate:"required"`
package models
// Author represent the author model
type Author struct {
ID int64 `json:"id"`
Name string `json:"name"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}
scalar Time
type Article {
ID: Int
Title: String
Content: String
UpdatedAt: Time
CreatedAt: Time
}
package article
import (
"context"
"github.com/ridhoperdana/go-clean-arch/models"
)
// Usecase represent the article's usecases
type Usecase interface {
type Query {
FetchArticle(after: String, first: Int): ArticlesResult
GetArticleByID(id: Int): Article
GetArticleByTitle(title: String): Article
}
type Mutation {
UpdateArticle(id: Int, title: String, content: String): Article
StoreArticle(title: String, content: String): Article
DeleteArticle(id: Int): Int
type Edge {
cursor: String
node: Article
}
type PageInfo {
endCursor: String
hasNextPage: Boolean
}