DEV Community

Discussion on: Creating an opinionated GraphQL server with Go - Part 3

Collapse
 
jessequinn profile image
Jesse Quinn

great work here, but i wanted to make you aware of some possible issues.

first with realize I had to use the following

        commands:
            install:
                status: true
                method: go build -o build/gql-server
            run:
                status: true
                method: build/gql-server

otherwise exec not started occurs.

For mysql users some modifications are needed namely the base.go should have the following ID

    ID        uuid.UUID  `gorm:"primary_key;type:varchar(36)"`

also you need to implement the BeforeCreate

// BeforeCreate will set a UUID rather than numeric ID.
func (base *BaseModel) BeforeCreate(scope *gorm.Scope) error {
    uuid, err := uuid.NewV4()
    if err != nil {
        return err
    }
    return scope.SetColumn("ID", uuid)
}