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

Variable transformations called by convert_input.go not defined in utils-go/boilergql/v3@v3.0.0/convert.go #52

Closed orible closed 7 months ago

orible commented 3 years ago

Following transformation functions not declared by package boilergql ("github.com/web-ridge/utils-go/boilergql/v3/convert.go")

Float32ToFloat64 Float64ToFloat32 PointerFloat64ToFloat32

PointerIntToInt8 PointerIntToUint UintToString StringToUint PointerStringToUint

PointerStringToNullDotJSON PointerStringToTypesJSON StringToTypesJSON TypesJSONToString

Special case this one, In order to get the SQLBoiler type, null.JSON to pass the schema step, I added a condition to output the json type as a string field.

Not sure how to fix this problem, I was thinking the library could just send out the value of the json object as a string, or undefined/empty if !Valid or null (github.com/volatiletech/null/v8/json.go)

RichardLindhout commented 3 years ago

Hey we need to add these functions to the go utils directory only for null.Json it should generate function names per type. Why do you want to output to string and not the json itself?

Screenshot_20210115-094057

RichardLindhout commented 3 years ago

In my case I want the json to be like json in graphql and not as hardcoded string + type safe or do you have really dynamic json in your db?

Otherwise I would recommend to make the type in your gqlgen schema and converting it like the image on top.

orible commented 3 years ago

Why do you want to output to string and not the json itself?

~Ah, I'm relatively new to graphQL, I assumed that the schema might not work with output that isn't a pre typed interface~

I see, I follow, my first problem before adding

if strings.Contains(lowerBoilerType, "json") { return "String" }

to sqlboiler_graphql_schema.go

Was that the compile phase didn't know what to do with a generic null.JSON output,

// UserNotification is an object representing the database table

type UserNotification struct {

ID        uint       "boil:"id" json:"id" toml:"id" yaml:"id""
UserID    uint       "boil:"user_id" json:"user_id" toml:"user_id" yaml:"user_id""
Data      types.JSON "boil:"data" json:"data" toml:"data" yaml:"data""
CreatedAt time.Time  "boil:"created_at" json:"created_at" toml:"created_at" yaml:"created_at""
R *userNotificationR "boil:"-" json:"-" toml:"-" yaml:"-""
L userNotificationL  "boil:"-" json:"-" toml:"-" yaml:"-""
}

This is the sort of use case where I have json output.

RichardLindhout commented 7 months ago

We now support JSON scalars: https://github.com/web-ridge/utils-go