-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Arg unpacking issue #52
Comments
That generates func UnmarshalCatalogFilter(v interface{}) (CatalogFilter, error) {
var it CatalogFilter
for k, v := range v.(map[string]interface{}) {
switch k {
case "OR":
var err error
rawIf1 := v.([]interface{})
it.OR = make([]CatalogFilter, len(rawIf1))
for idx1 := range rawIf1 {
it.OR[idx1], err = UnmarshalCatalogFilter(rawIf1[idx1])
}
if err != nil {
return it, err
}
case "AND":
var err error
rawIf1 := v.([]interface{})
it.AND = make([]CatalogFilter, len(rawIf1))
for idx1 := range rawIf1 {
it.AND[idx1], err = UnmarshalCatalogFilter(rawIf1[idx1])
}
if err != nil {
return it, err
}
case "id":
var err error
it.ID, err = graphql.UnmarshalInt(v)
if err != nil {
return it, err
}
}
}
return it, nil
} Which looks fine to me, are you up to date? #30 fixed a few issues around input generation. |
hmm your right that one does generate ok. I gave you a bad example let me try again. This one definitely generates the wrong code. I just updated my dependencies and tried again.
Schema
Looking at the implementations the difference between the two one is a pointer to a slice while the other is the slice itself
So now im not sure if this is a bug on your side or we can just change it to be the slice instead of the pointer. Or you want the code generation to cover both ways. |
I would suggest using generated input objects to avoid hand crafting them, but this should definitely "just work". |
ya we will do that going forward, this is a "legacy" graphql using neelance so we have all the structs already created. |
Hi @vektah as requested here is a sample schema for the issue I saw. It is an input with a recursive type of itself.
I pasted the code generated in the other issue, I think the issue is somewhere in the
unmarshal
func on line 84 in type.goThe text was updated successfully, but these errors were encountered: