tarsius-cli
Create project
Create new project
$ mkdir project-test
$ cd project-test
Create tarsius.yml for data modeling
tables :
author:
id:
type: serial
notNull: true
primaryKey: true
name:
type: varchar(100)
notNull: true
email:
type: varchar(150)
notNull: true
created:
type: timestamptz
post:
id:
type: serial
notNull: true
primaryKey: true
title:
type: varchar(100)
notNull: true
content:
type: text
authorid:
type: authors.id
notNull: true
created:
type: timestamptz
use anchor
tables :
author:
id: &idAnchor
type: serial
notNull: true
primaryKey: true
name: &nameAnchor
type: varchar(100)
notNull: true
email:
<<: *nameAnchor
created: &dateAnchor
type: timestamptz
post:
id:
<<: *idAnchor
title:
<<: *nameAnchor
content:
type: text
authorid:
type: authors.id
notNull: true
created:
<<: *dateAnchor
SQL
Configuration
$ tarsius-cli sql config
Create table
$ tarsius-cli sql create
Initialize your project
$ tarsius-cli init
or
$ tarsius-cli init -s go -p ../project-directory
Run project
$ tarsius-cli run
access to http://localhost:8000
GraphQL
Query to get the all authors
query {
authors {
id
name
email
created
}
}
Query to get a specific author
query {
author(id: 1) {
id
name
email
}
}
Create new author using mutation
mutation {
createAuthor(name: "Ibnu Yahya", email: "ibnu@tarsius.id") {
id
name
email
}
}
Update an author using mutation
mutation {
updateAuthor(id: 2, name: "ibnu Yahya", email: "ibnu@tarsius.id") {
id
name
email
}
}
Delete an author using mutation
mutation {
deleteAuthor(id: 2) {
id
}
}
Query to get the posts with its relation author
query {
posts {
id
title
content
author {
id
name
email
}
}
}