A graphql webservice made using go
although some input are nullable in sql, for pass the input(argument) and making model there is no way to pass a nil pointer. To solve this problem, default value are made for each data type:
- Time (datetime) : "1900-01-01T00:00:00.000Z"
- String : "" (not tested)
- int : 0
- bool : false or 0
If 8080 blocked, try any port that not in this list netsh interface ipv4 show excludedportrange protocol=tcp
for newly project: go run github.com/99designs/gqlgen init
If new object/schema added, then new model need to generated. Run this code: go run github.com/99designs/gqlgen generate More: github.com/99designs/gqlgen
cd internal/pkg/db/migrations/ migrate create -ext sql -dir mssql -seq create_[$name]_table
use force => edit m.force(n) in db file. n: latest ver +1 OR delete schema_migrations table in th db check docs in: https://github.com/golang-migrate/migrate
$ migrate -source file://path/to/migrations -database postgres://localhost:5432/database up 2 example for mysql: $ migrate -database mysql://root:dbpass@/hackernews -path internal/pkg/db/migrations/mysql up
migrate -database sqlserver://ASUS:12345678@/sobat -path internal/pkg/db/migrations/mssql up migrate -database sqlserver://ASUS:12345678@localhost:1433/sobat -path internal/pkg/db/migrations/mssql up sqlserver://ASUS:12345678@localhost?database=sobat
Error migration: Dirty database version 1. Fix and force version. How to fix: migrate -path PATH_TO_YOUR_MIGRATIONS -database YOUR_DATABASE_URL force VERSION *change version with a number of force migrate -database sqlserver://ASUS:12345678@localhost:1433/sobat -path internal/pkg/db/migrations/mssql up force 5
Full length : "2006-01-02T15:04:05.999999999Z" (UTC ) "2006-01-02T15:04:05.999999999+03:30" (A DateTime with +3h 30min offset)
mutation { createUser(input: {username: "user123", password: "123"}) } mutation { createKegiatan(input: {title: "kegiatan 1", status: "jalan"}) { title status } }
{ "Authorization": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9" }
Model cannot accept nil