Closed AlexSwiss closed 4 years ago
Have you run sqlboiler mysql --no-back-referencing
to generate your base models.
This plugin reads the models directory generated by: https://github.com/volatiletech/sqlboiler
when i run that is says unknown flag: --no-back-referencing
but when i also run it without the flag is generates the models folder
Ah nice that means you're not on the latest version of sqlboiler that is important or else your program will crash because it keeps referencing itself in the converts
If you run
go get -u -t github.com/volatiletech/sqlboiler
It should update itself. It's important you run that at the root of your computer, not in a GOPATH directory.
➜ **~** go get -u -t github.com/volatiletech/sqlboiler
Your convert_config.go should look like this
// +build ignore
package main
import (
"fmt"
"os"
"github.com/99designs/gqlgen/api"
"github.com/99designs/gqlgen/codegen/config"
// gbgen "github.com/web-ridge/gqlgen-sqlboiler" // only when removed go.mod
gbgen "github.com/web-ridge/gqlgen-sqlboiler/v2"
)
func main() {
cfg, err := config.LoadConfigFromDefaultLocations()
if err != nil {
fmt.Fprintln(os.Stderr, "failed to load config", err.Error())
os.Exit(2)
}
convertHelpersDir := "helpers"
sqlboilerDir := "models"
gqlgenModelDir := "graphql_models"
err = api.Generate(cfg,
api.AddPlugin(gbgen.NewConvertPlugin(
convertHelpersDir, // directory where convert.go, convert_input.go and preload.go should live
sqlboilerDir, // directory where sqlboiler files are put
gqlgenModelDir, // directory where gqlgen models live
)),
api.AddPlugin(gbgen.NewResolverPlugin(
convertHelpersDir,
sqlboilerDir,
gqlgenModelDir,
"github.com/web-ridge/gqlgen-sqlboiler-examples/social-network/auth",
)),
)
if err != nil {
fmt.Println("error!!")
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(3)
}
}
i checked my go.mod file and it keeps installing the v3.7 which it says "incompactible" i tried getting a specific version using @v4.1.1 , but it says major version must be compactible
my covert_plugin file is okay.
Hmm strange maybe remove the all the folders models and go.mod and go.sum and try again
Could and then run go mod init, could you share your go.mod
In v2.1.0 we have support for custom directories so you'll have more options to where you want your imports and output!
Closing this issue as the root issue of this is fixed in v2.1.0
when i run convert_plugin.go after setting up everything i encounter this error
[covert] render filter.gotp; renderError template.gotpl: template: template.gotpl:27:3: executing "template.gotpl" at <reserveImport $.BackendModelsPath>: error calling reserveImport: empty ambient import