https://github.com/lfscamargo/graphql-go-boierplate
A simple boilerplate for GoLang GraphQL server
https://github.com/lfscamargo/graphql-go-boierplate
Last synced: 9 months ago
JSON representation
A simple boilerplate for GoLang GraphQL server
- Host: GitHub
- URL: https://github.com/lfscamargo/graphql-go-boierplate
- Owner: LFSCamargo
- Created: 2020-12-25T09:09:22.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-12-28T13:13:27.000Z (over 5 years ago)
- Last Synced: 2025-04-11T01:12:34.473Z (over 1 year ago)
- Language: Go
- Size: 28.3 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
Go Lang GraphQL Boilerplate
This is my GraphQL Boilerplate for starters at Go and GraphQL
# Why i created this?
I was studying Go Lang and i did not found any great tutorial of how to build a simple GraphQL server with authentication and with password hashing
# What you need to know?
There are three stuff that you need to know about this boilerplate
## What database is beign used?
MongoDB, and for managing i'm using the `mgm` that is a ODM for mongo, and the models that i create are all inside the `database/models` folder. You can create your models inside that folder like this: `database/models/user/user.go`
## What is being used to handle GraphQL?
GQL Gen, the graphql gen it's a pretty easy solution to work with GraphQL with Go!
It has some tools to help you develop faster you just need to change the schema and run the following command to generate the models and resolvers skeleton:
```sh
go run github.com/99designs/gqlgen
```
It will generate a model inside the file `graph/model/models_gen.go` folder and also will create the resolvers for you automatically inside `graph/schema.resolvers.go`, but there are two things that you need to know:
1. The models should not be edited because they are generated based on the `graph/schema.graphqls`
2. You can edit the `graph/schema.resolvers.go` but when you run the gql gen command will create resolvers but without any kind of logic inside
# How to run the project
1. Clone the repo
2. Enter the project folder and run the following command to install the deps `go mod download`
3. Run the `go run server.go` and you should be fine