web-ridge / gqlgen-sqlboiler

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

Allow user to override generated functions in convert #7

Closed RichardLindhout closed 3 years ago

RichardLindhout commented 4 years ago

Do a three-way-diff merge for changes and let user choose parts of code which should not take over generated code.

{defaultNameOfResolver}_custom.go Every function which is stated there will be skipped in generation.

RichardLindhout commented 3 years ago

The program will now look in the package and look for functions with the same name as the generated one's. If a custom one exist e.g.

convert_override.go

package helpers

import (
    "github.com/../app/backend/graphql_models"
    "github.com/../app/backend/models"
)

func UserCreateInputToBoiler(
    m *graphql_models.UserCreateInput,
) *models.User {
    if m == nil {
        return nil
    }

    originalConvert := originalUserCreateInputToBoiler(m)
    // TODO: bcryp pass
    return originalConvert
}

The function in the template get's changed to userCreateInputToBoiler

RichardLindhout commented 3 years ago

Released in v3.1.0