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

func BooleanFilterToMods has empty body #22

Closed troian closed 4 years ago

troian commented 4 years ago
func BooleanFilterToMods(m *graphql_models.BooleanFilter, column string) []qm.QueryMod {

    return nil
}
RichardLindhout commented 4 years ago

That's right can you make a PR for that? I did not have boolean usecase yet so not fully sure how to make working queries for it

RichardLindhout commented 4 years ago

This should probably work not really sure if this is ideal though. It should probably just be a boolean with support for this: https://github.com/web-ridge/gqlgen-sqlboiler/issues/17#issuecomment-626584956

Maybe we should have it more like string filtering or instead of BooleanFIlter just a boolean

func BooleanFilterToMods(m *graphql_models.BooleanFilter, column string) []qm.QueryMod {
    if m == nil {
        return nil
    }
    var queryMods []qm.QueryMod
    if m.IsFalse != nil {
        queryMods = append(queryMods, qmhelper.Where(column, qmhelper.EQ, false))
    }
    if m.IsTrue != nil {
        queryMods = append(queryMods, qmhelper.Where(column, qmhelper.EQ, true))
    }
    if m.IsNull != nil {
        queryMods = append(queryMods, qmhelper.Where(column, qmhelper.EQ, nil))
    }
    return queryMods
}
troian commented 4 years ago

The Sample you've provided exactly same what we've ended up with)

RichardLindhout commented 4 years ago

Are you in favor of changing input in scheme to:

input BooleanFilter {
  equalTo: Boolean
  notEqualTo: Boolean
}
troian commented 4 years ago

Yah, sounds good

RichardLindhout commented 4 years ago

Fixed in v2.0.12