Love my work? Drop me a coffee here. :)
GraphQL-based Service with Go-Chi
Global Template Repository for Development and Operations Of Your Projects.
Table of Contents
Getting Started
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
Prerequisites
What things you need to install the software and how to install them
apt-get -y install git
Or
yum -y install git
Installation
A step by step series of examples that tell you how to get a development env running
Say what the step will be clone this repository.
git clone git@github.com:ardihikaru/graphql-example-part-1.git
Development
Usage
Reference and programming instructional materials.
Generate private and public key
Using GraphQL Generator
- Cli command to use (one by one)
go get github.com/99designs/gqlgen@v0.17.45
go run github.com/99designs/gqlgen generate
- Cli command to use (at once)
go get github.com/99designs/gqlgen@v0.17.45 && go run github.com/99designs/gqlgen generate
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
Looking to contribute to our code but need some help? There's a few ways to get information:
Versioning
We use SemVer for versioning. For the versions available, see the tags on this repository.
Authors
License
This project is licensed under the MIT License - see the LICENSE file for details
Copyright © 2024 Public Use. All Rights Reserved.
Acknowledgments
- Hat tip to anyone whose code was used
- Inspiration
- etc
MISC
curl -v --request OPTIONS 'http://localhost:8080/public/service-id' -H 'Origin: http://other-domain.com' -H 'Access-Control-Request-Method: GET'
curl -v --request OPTIONS 'http://localhost:8080/auth/login' -H 'Origin: http://other-domain.com' -H 'Access-Control-Request-Method: POST'
curl -v -X OPTIONS \
http://localhost:8080/public/service-id \
-H 'cache-control: no-cache' \
-F Origin=http://www.google.com
- Allowed CORS result (please set
cors.Debug: true
)
[cors] 2024/06/16 23:53:13 Handler: Preflight request
[cors] 2024/06/16 23:53:13 Preflight response headers: map[Access-Control-Allow-Methods:[GET] Access-Control-Allow-Origin:[http://other-domain.com] Access-Control-Max-Age:[6000] Vary:[Origin Access-Control-Request-Method Access-Control-Request-Headers]]
- NOT Allowed CORS result (please set
cors.Debug: true
)
[cors] 2024/06/16 23:52:13 Handler: Preflight request
[cors] 2024/06/16 23:52:13 Preflight aborted: origin 'http://other-domain.com' not allowed
Create new module:
kalau ada yg kurang
go get github.com/99designs/gqlgen@v0.17.45
-
Create graphqls file for the module: edit graph/graphqls/{module_name}.graphqls
-
Generate model & resolvers:
go run github.com/99designs/gqlgen generate
-
Resolvers implementation: edit graph/resolvers/{module_name}.resolvers.go
-
Run:
go run server.go 8080
Penambahan db Sequence connector