···6677The goal is to be able to focus on the business logic, and not re-implement things that are already defined in schemas.
8899-### Commands
99+## Schemas as source of truth
1010+1111+### Database schema: goose
1212+1313+1. Add a new migration file into pkg/pgdb/schema
1414+2. Run the server (`go run server.go`)
1515+1616+### Data management: sqlc
1717+1818+1. Add new queries or commands to `pkg/pgdb/query.sql`
1919+2. Run `go generate ./...`
10201111-- `goose -dir pkg/pgdb/schema up`
2121+### GraphQL API: gqlgen
2222+2323+1. Make the necessary schema changes
2424+2. Run `go generate ./...`
···11-# Where are all the schema files located? globs are supported eg src/**/*.graphqls
22-schema:
33- - graph/*.graphqls
44-55-# Where should the generated server code go?
66-exec:
77- filename: graph/generated/generated.go
88- package: generated
99-1010-# Uncomment to enable federation
1111-# federation:
1212-# filename: graph/generated/federation.go
1313-# package: generated
1414-1515-# Where should any generated models go?
1616-model:
1717- filename: graph/model/models_gen.go
1818- package: model
1919-2020-# Where should the resolver implementations go?
2121-resolver:
2222- layout: follow-schema
2323- dir: graph
2424- package: graph
2525-2626-# Optional: turn on use ` + "`" + `gqlgen:"fieldName"` + "`" + ` tags in your models
2727-# struct_tag: json
2828-2929-# Optional: turn on to use []Thing instead of []*Thing
3030-# omit_slice_element_pointers: false
3131-3232-# Optional: turn off to make struct-type struct fields not use pointers
3333-# e.g. type Thing struct { FieldA OtherThing } instead of { FieldA *OtherThing }
3434-# struct_fields_always_pointers: true
3535-3636-# Optional: turn off to make resolvers return values instead of pointers for structs
3737-# resolvers_always_return_pointers: true
3838-3939-# Optional: set to speed up generation time by not performing a final validation pass.
4040-# skip_validation: true
4141-4242-# gqlgen will search for any type names in the schema in these go packages
4343-# if they match it will use them, otherwise it will generate them.
4444-autobind:
4545-# - "github.com/andrioid/gostack-gql/graph/model"
4646-4747-# This section declares type mapping between the GraphQL and go type systems
4848-#
4949-# The first line in each type will be used as defaults for resolver arguments and
5050-# modelgen, the others will be allowed when binding to fields. Configure them to
5151-# your liking
5252-models:
5353- ID:
5454- model:
5555- - github.com/99designs/gqlgen/graphql.ID
5656- - github.com/99designs/gqlgen/graphql.Int
5757- - github.com/99designs/gqlgen/graphql.Int64
5858- - github.com/99designs/gqlgen/graphql.Int32
5959- Int:
6060- model:
6161- - github.com/99designs/gqlgen/graphql.Int
6262- - github.com/99designs/gqlgen/graphql.Int64
6363- - github.com/99designs/gqlgen/graphql.Int32
···11package graph
2233+//go:generate go run github.com/99designs/gqlgen generate
44+35// This file will not be regenerated automatically.
46//
57// It serves as dependency injection for your app, add any dependencies you require here.