shurcooL/githubv4

Can't decode array

aiden-dev opened this issue · 2 comments

I'm trying to do a simple request but it gets stuck on categories every time.

Request:

var query struct {
   StoreCategory struct {
      categories []struct {
         pageData struct {
            title string
         }
      }
   } `graphql:"StoreCategory"`
}
	
client.Query(context.Background(), &query, nil)

Response:

{
    "data": {
        "StoreCategory": {
            "categories": [
                {
                    "pageData": {
                        "title": "1"
                    }
                },
                {
                    "pageData": {
                        "title": "2"
                    }
                }
            ]
        }
    }
}

Error:
Error: Message: struct field for "categories" doesn't exist in any of 1 places to unmarshal, Locations: [], Extensions: map[code:graphql_decode_error]

Try making your query fields exported. Categories instead of categories, PageData not pageData, and Title not title.

Thanks so much