web-ridge / gqlgen-sqlboiler

This is a plugin for gqlgen to generate converts + filter queries and resolvers for sqlboiler
MIT License
74 stars 13 forks source link

Wrong field name & empty type #26

Closed ggalan87 closed 4 years ago

ggalan87 commented 4 years ago

I got a wrong schema which I think it is caused due to bug while parsing the boiler struct. As you see below I have a field UserID which is not parsed correctly and eventually results to wrong generated field and empty type. Some other irrelevant part of the structs are omitted.

sqlboiler:

type Member struct {
    UserID   int    `boil:"user_id" json:"user_id" toml:"user_id" yaml:"user_id"`
    Username string `boil:"username" json:"username" toml:"username" yaml:"username"`
    RealName string `boil:"real_name" json:"real_name" toml:"real_name" yaml:"real_name"`
}

generated

type Member {
    user: !
    username: String!
    realName: String!
}
RichardLindhout commented 4 years ago

Is user id the primary key here? We only support ID as primary Id at the moment but I'm open to improve that.

RichardLindhout commented 4 years ago

The program thinks userID is a foreign key now and tries look it up in the .R struct of the member

ggalan87 commented 4 years ago

Yes it is primary key... The database and API is work in progress so I don't mind changing the spec either in the database or rename the field while generating the sqlboiler model. Thank you!

RichardLindhout commented 4 years ago

Perfect!