Skip to content

Commit

Permalink
Add debugging details to readme (shurcooL#109)
Browse files Browse the repository at this point in the history
* Add debugging details to readme

---------

Co-authored-by: Toan Nguyen <[email protected]>
  • Loading branch information
zdevaty and hgiasac authored Sep 18, 2023
1 parent b261afa commit 43b90bc
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -906,23 +906,24 @@ Enable debug mode with the `WithDebug` function. If the request is failed, the r
}
```
Because the GraphQL query string is generated in runtime using reflection, it isn't really safe. To assure the GraphQL query is expected, it's necessary to write some unit test for query construction.
For debugging queries, you can use `Construct*` functions to see what the generated query looks like:
```go
// ConstructQuery build GraphQL query string from struct and variables
func ConstructQuery(v interface{}, variables map[string]interface{}, options ...Option) (string, error)

// ConstructQuery build GraphQL mutation string from struct and variables
// ConstructMutation build GraphQL mutation string from struct and variables
func ConstructMutation(v interface{}, variables map[string]interface{}, options ...Option) (string, error)

// ConstructSubscription build GraphQL subscription string from struct and variables
func ConstructSubscription(v interface{}, variables map[string]interface{}, options ...Option) (string, error)
func ConstructSubscription(v interface{}, variables map[string]interface{}, options ...Option) (string, string, error)

// UnmarshalGraphQL parses the JSON-encoded GraphQL response data and stores
// the result in the GraphQL query data structure pointed to by v.
func UnmarshalGraphQL(data []byte, v interface{}) error
```
Because the GraphQL query string is generated in runtime using reflection, it isn't really safe. To assure the GraphQL query is expected, it's necessary to write some unit test for query construction.
Directories
-----------
Expand Down

0 comments on commit 43b90bc

Please sign in to comment.