An example go web server implementing a GraphQL api with a Sqlite database.
Read the full article: https://shellbear.me/blog/go-graphql-api
Using go run:
> go run main.go
2020/xx/xx xx:xx:xx connect to http://127.0.0.1:8080/ for GraphQL playgroundUsing go build:
> go build -o go-graphql-example .
> ./go-graphql-example
2020/xx/xx xx:xx:xx connect to http://127.0.0.1:8080/ for GraphQL playgroundYou can access the GraphQL playground at: http://127.0.1:8080/
After making changes to ent/schema or graph directory make sure to run the generate command:
go generate ./...Database models are handled with ent.
Follow the instructions to install the ent CLI.
To add a new model:
ent init [Model]And start editing the new Model schema in ent/schema/[model].go.
Then run the code generation tool:
go generate ./...GraphQL API is managed with gqlgen.
To update the API, edit the schema in graph/schema.graphqls or a create a new schema named: graph/*.graphqls.
After making changes, run the code generation tool:
go generate ./...And implement code logic inside graph/[schema].resolers.go.

