thunder icon indicating copy to clipboard operation
thunder copied to clipboard

Base struct fields are not recognized

Open jjacobson93 opened this issue 5 years ago • 2 comments

I'm using a base struct for some common fields in my model, for example, an ID field. It seems when using a struct that has the base struct, those fields are not recognized by the library.

For example, this will not work:

type Base struct {
    ID string
}

type User struct {
    Base
    Email string
}

The query here fails with unknown field "id"

query {
    users {
        id
    }
}

jjacobson93 avatar Jun 09 '19 22:06 jjacobson93

I dug into the code a bit. Since the base/embedded struct is just another field, it probably needs to be handled here.

The field Anonymous on reflect.StructField could possibly be used to determine whether or not to recursively look for additional base struct fields.

jjacobson93 avatar Jun 09 '19 22:06 jjacobson93

Has any progress been made as this would be usefull for my project?

oscartbeaumont avatar Dec 23 '19 10:12 oscartbeaumont