Go is used to create scalable infra. Learn more about Go here and setting up Go in Linux.
Schema.graphqls -> schema.resolvers.go -> logic/getLogic.go -> postgres -> pqueries.go
this is for linux export PATH=$PATH:/usr/local/go/bin export GOPATH=/usr/local/go
go version go env
mkdir projectname cd projectname
- gqlgen - GraphQL
- pgx - PostgreSQL
- GQLGEN Doc
- To understand more about gqlgen.yml: https://gqlgen.com/config/
- Facing issue with migrate(github.com/golang-migrate/migrate v3.5.4+incompatible)
- Use go get -tags 'postgres' -u github.com/golang-migrate/migrate/v4/cmd/migrate/
-
Initialize Project: go mod init github.com/Divan009/gqlgen-todos
-
Get Dependency: go get github.com/99designs/gqlgen
-
Setup Project: go run github.com/99designs/gqlgen init
-
Run Project: go run ./server.go
-
Whenever you want to Generate the Schema file, use: go run github.com/99designs/gqlgen generate
-
JWT go get github.com/dgrijalva/jwt-go
CREATE TABLE IF NOT EXISTS Users( ID INT NOT NULL UNIQUE AUTO_INCREMENT, Username VARCHAR (127) NOT NULL UNIQUE, Password VARCHAR (127) NOT NULL, PRIMARY KEY (ID) )
CREATE TABLE IF NOT EXISTS Links( ID INT NOT NULL UNIQUE AUTO_INCREMENT, Title VARCHAR (255) , Address VARCHAR (255) , UserID INT , FOREIGN KEY (UserID) REFERENCES Users(ID) , PRIMARY KEY (ID) )
-
Schema.graphqls - basically where i define the structure or what is to be returned from API. This is the first thing I do.
-
Model_gen - This gets generated from the above schema.
-
Schema_resolver - for all your functions
-
Postgres - I create Db and call it
-
pqueries - is where i define db functions
-
getLogic - uses the pqueries func
-
jwt