Gqlmodel custom models for gqlgen.com grqphql module.
go get github.com/ubgo/gqlmodel
Note: If you are getting error modelgen: unable to find type github.com/ubgo/gqlmodel.UidScalar
then create a new go file or use existing go file and add below code
import _ github.com/ubgo/gqlmodel
- uuid.UUID
- Edit the
gqlgen.yml
file and add the code like this undermodels
Uid:
model: github.com/ubgo/gqlmodel.UidScalar
- Under your
schema.graphqls
file add thisscalar Uid
- Now you can use the UUID like this:
type Category {
id: Uid!
name: String!
}
You will see the model file generated as following:
type Category struct {
ID uuid.UUID `json:"id"`
Name string `json:"name"`
}
If you would like to contribute to the project, please fork it and send us a pull request. Please add tests for any new features or bug fixes.
- Author - Aman Khanakia
- Website - https://khanakia.com
goutil is MIT licensed.