From 3c1579701ce269c69f297da04eb508ca2f7d69e9 Mon Sep 17 00:00:00 2001 From: simobiggs Date: Thu, 5 Mar 2020 15:47:30 +0100 Subject: [PATCH 1/2] Update README to show field renaming --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 2836c7e..2c7f9f7 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,13 @@ $ go get github.com/machinebox/graphql ```go import "context" +type ResponseStruct struct { + field1 string + field2 string + field2 string + ID string `json:"_id"` // GQL fields may be renamed as per normal json +} + // create a client (safe to share across requests) client := graphql.NewClient("https://machinebox.io/graphql") @@ -31,6 +38,7 @@ req := graphql.NewRequest(` field1 field2 field3 + _id } } `) From 2d7c7d108763a716b0c8ea9b6179cd92346ef73e Mon Sep 17 00:00:00 2001 From: simobiggs Date: Thu, 5 Mar 2020 15:52:00 +0100 Subject: [PATCH 2/2] Make the example code really work --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2c7f9f7..cce8c66 100644 --- a/README.md +++ b/README.md @@ -21,13 +21,17 @@ $ go get github.com/machinebox/graphql ```go import "context" -type ResponseStruct struct { +type Items { field1 string field2 string field2 string ID string `json:"_id"` // GQL fields may be renamed as per normal json } +type ResponseStruct struct { + items Items +} + // create a client (safe to share across requests) client := graphql.NewClient("https://machinebox.io/graphql")