This file contains hidden or 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
docker: | |
driver: postgres | |
dsn: postgres://mediumexample:me1234@localhost:5432/example?sslmode=disable |
This file contains hidden or 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
// +build ignore | |
package main | |
import "github.com/99designs/gqlgen/cmd" | |
func main() { | |
cmd.Execute() | |
} |
This file contains hidden or 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
package mediumexample | |
import "time" | |
// Address hold address information returned by AddressStore | |
type Address struct { | |
UserID string `json:"user_id,omitempty" db:"user_id"` | |
AddressLine string `json:"address_line,omitempty" db:"address_line"` | |
City string `json:"city,omitempty" db:"city"` | |
Locality string `json:"locality,omitempty" db:"locality"` |
This file contains hidden or 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
package mediumexample | |
import ( | |
"errors" | |
"time" | |
) | |
// User hold user information returned by UserService | |
type User struct { | |
ID string `json:"id,omitempty" db:"id"` |
This file contains hidden or 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
schema: | |
- schema.graphql | |
exec: | |
filename: graphql/generated.go | |
resolver: | |
filename: graphql/resolver.go | |
type: Resolver | |
models: | |
User: | |
model: github.com/rodrwan/medium-example.User |
This file contains hidden or 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 User { | |
id: ID! | |
email: String! | |
first_name: String! | |
last_name: String! | |
phone: String! | |
birthdate: Time! | |
address: Address! | |
} |
This file contains hidden or 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
package postgres | |
import ( | |
"crypto/rand" | |
"database/sql" | |
"encoding/base64" | |
"fmt" | |
"strings" | |
"time" |
This file contains hidden or 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
package postgres | |
import ( | |
"unicode" | |
"golang.org/x/text/transform" | |
"golang.org/x/text/unicode/norm" | |
"github.com/jmoiron/sqlx" | |
"github.com/lib/pq" |
This file contains hidden or 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
func main() { | |
postgresDSN := flag.String( | |
"postgres-dsn", "postgres://localhost:5432/graph_test?sslmode=disable", "Postgres DSN") | |
flag.Parse() | |
db, err := postgres.New(*postgresDSN) | |
check(err) | |
us := &postgres.UserService{ | |
Store: db, |
This file contains hidden or 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
// Address hold adderss information returned by AddressStore | |
type Address struct { | |
UserID string `json:"user_id,omitempty" db:"user_id"` | |
AddressLine string `json:"address_line,omitempty" db:"address_line"` | |
City string `json:"city,omitempty" db:"city"` | |
Locality string `json:"locality,omitempty" db:"locality"` | |
AdministrativeAreaLevel1 string `json:"administrative_area_level_1,omitempty" db:"administrative_area_level_1"` | |
Country string `json:"country,omitempty" db:"country"` | |
PostalCode int `json:"postal_code,omitempty" db:"postal_code"` | |
} |