machinebox / graphql

Simple low-level GraphQL HTTP client for Go
https://blog.machinebox.io/a-graphql-client-library-for-go-5bffd0455878
Apache License 2.0
933 stars 217 forks source link

More documents or examples for ResponseStruct may be helpful #40

Open neoli0222 opened 5 years ago

neoli0222 commented 5 years ago

For a query or mutation, we must use a wrapper struct as the response struct. This is very counterintuitive and should be pointed out in the example. For example, for the following query, type Query { lesson(id: ID!): Lesson! } We need the following wrapper struct as the response, type RespData { Lesson: Lesson json: "lesson" } Or we can do as following: var respData map[string]interface{} convertMapDataToLesson(respData)