hasura / go-graphql-client

Package graphql provides a GraphQL client implementation.
MIT License
395 stars 91 forks source link

map[string]interface{} not working #133

Open kotyara85 opened 6 months ago

kotyara85 commented 6 months ago

Hello there, So I have this struct

type serviceAccount struct {
    Name           graphql.String
    Labels           map[string]interfaces{}
}

which results into

 failed to write query for struct field `Labels`: type map[string]interface {} is not supported, use [][2]interface{} instead

Is there a way to unmarhal this?

Thanks

hgiasac commented 6 months ago

Hello @kotyara85,

You can try to add scalar:"true" tag to that field. The library will ignore inferring nested fields and decode directly.

type serviceAccount struct {
    Name           graphql.String
    Labels           map[string]interfaces{} `scalar:"true"`
}