dillonkearns/elm-graphql

Handling .id_

dotnetspec opened this issue · 1 comments

Using the elm-graphql auto generated files:

SRdb.Object.User is unable to handle 'SRdb.Object.User.id_':
userSelectionSet : SelectionSet decodesTo SRdb.Object.User
userSelectionSet =
    Graphql.SelectionSet.succeed SRdb.Object.User
        |> Graphql.SelectionSet.with SRdb.Object.User.id_

I get:

This function cannot handle the argument sent through the (|>) pipe:
148|     Graphql.SelectionSet.succeed SRdb.Object.User
149|         |> Graphql.SelectionSet.with SRdb.Object.User.id_
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The argument is:
    SelectionSet SRdb.Object.User SRdb.Object.User

But (|>) is piping it to a function that expects:
    SelectionSet (SRdb.ScalarCodecs.Id -> b) SRdb.Object.User

How should I define the userSelectionSet if 'SRdb.Object.User.id_' won't handle the incoming id_? thanks

I need to define a separate FUser type/constructor function with field 'id_' to handle the id_:

type alias FUser =
    { id_ : SRdb.ScalarCodecs.Id
    , ...
    }

I should not be using 'SRdb.Object.User' (a typelock) to do this.

Rather it would be: Graphql.SelectionSet.succeed FUser ...