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 struct { | |
| ID string `json:"id" db:"id"` | |
| FirstName string `json:"first_name" db:"first_name"` | |
| LastName string `json:"last_name" db:"last_name"` | |
| Email string `json:"email" db:"email"` | |
| Birthdate time.Time `json:"birthdate" db:"birthdate"` | |
| DNI string `json:"dni" db:"dni"` | |
| DNIType string `json:"dni_type" db:"dni_type"` | |
| FamilyStatus string `json:"family_status" db:"family_status"` | |
| Gender string `json:"gender" db:"gender"` |
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 types | |
| import ( | |
| "github.com/rodrwan/gateway" | |
| "github.com/graphql-go/graphql" | |
| ) | |
| var User = graphql.NewObject(graphql.ObjectConfig{ | |
| Name: "User", | |
| Fields: graphql.Fields{ |
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 queries | |
| import ( | |
| "errors" | |
| "github.com/rodrwan/gateway" | |
| "github.com/rodrwan/gateway/graph" | |
| "github.com/rodrwan/gateway/graph/types" | |
| "github.com/graphql-go/graphql" | |
| ) |
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
| // User hold user information returned by UserService | |
| type User struct { | |
| ID string `json:"id,omitempty" db:"id"` | |
| Email string `json:"email,omitempty" db:"email"` | |
| FirstName string `json:"first_name,omitempty" db:"first_name"` | |
| LastName string `json:"last_name,omitempty" db:"last_name"` | |
| Phone string `json:"phone,omitempty" db:"phone"` | |
| Birthdate time.Time `json:"birthdate,omitempty" db:"birthdate"` |
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"` | |
| } |
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
| 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
| 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
| 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
| schema: | |
| - schema.graphql | |
| exec: | |
| filename: graphql/generated.go | |
| resolver: | |
| filename: graphql/resolver.go | |
| type: Resolver | |
| models: | |
| User: | |
| model: github.com/rodrwan/medium-example.User |