Releases: hasura/go-graphql-client
v0.11.0
What's Changed
- feat: add
Path []interface{}
field to GraphQL Error object by @dpulpeiro in #121 - feat: include error detail when retrying WebSocket timeout by @kacperdrobny in #123
- feat: add more WebSocket options for subscription client by @hgiasac in #126
New Contributors
- @dpulpeiro made their first contribution in #121
- @kacperdrobny made their first contribution in #123
Full Changelog: v0.10.2...v0.11.0
v0.10.2
v0.10.1
v0.10.0
Breaking changes
This release upgrades Go version to 1.20 with the latest dependencies. Don't upgrade this version if you don't plan to upgrade Go v1.20.
Changelog
- update gh actions and go versions, update deprecated ioutil (#98) @davidbloss
- jsonutil: ignore empty slice length when decoding (#102) @bill-rich
- set the operation name to the request payload if exists (#103) @pontusntengnas
v0.9.3
v0.9.2
This release adds new callback events for the subscription client that are useful for debugging and testing.
// OnConnectionAlive event is triggered whenever the WebSocket connection
// receives a connection alive message (differs per protocol)
client.OnConnectionAlive(fn func())
// OnSubscriptionComplete event is triggered when the subscription receives
// a terminated message from the server
client.OnSubscriptionComplete(fn func(sub Subscription))
New settings are also added to control the retry and exit behaviors of the subscription client.
client.WithoutLogTypes(graphql.GQLData, graphql.GQLConnectionKeepAlive).
// the client should exit when all subscriptions were closed, default true
WithExitWhenNoSubscription(false).
// WithRetryStatusCodes allow retrying the subscription connection when receiving one of these codes
// the input parameter can be a number string or range, e.g 4000-5000
WithRetryStatusCodes("4000", "4000-4050")
Changelog
- add
OnConnectionAlive
event to the subscription client (#77) @sermojohn - fix: prevent panic on late message after unsubscribed subscription (#79) @sermojohn
- improve the subscription life cycle events and add new settings (#82) @hgiasac
v0.9.1
Changelog
- improve the subscription client, fix goroutine leaks and data race issues (#76) @hgiasac
- merge the reset subscription logic into the
Run
method. If you call theRun
method when the subscription client is running, the client will restart the current connection. - print the extra
Extensions
information in theError
object
v0.9.0
Highlight
Support graphql-ws
protocol
The subscription client now supports 2 protocols:
The protocol can be switchable by the WithProtocol
function. By default, the subscription client uses the subscriptions-transport-ws
protocol.
client := graphql.NewSubscriptionClient("wss://example.com/graphql").
WithProtocol(graphql.GraphQLWS)
Changelog
- exposed the
UnmarshalGraphQL
function in thejsonutil
package (#62) @nico151999 - fix the dynamic GraphQL type output from the GraphQLType interface instance (#56) @hgiasac
- support
graphql-ws
protocol (#67) @hgiasac - allow using custom HTTP client that implements
Doer
interface (#68) @senekis - patch gin v1.7.7 to fix the security issue (#75) @hgiasac
v0.8.1
v0.8.0
Highlight
Introduce ExecRaw
method that returns a raw json message.
query := `query{something(where: { foo: { _eq: "bar" }}){id}}`
var res struct {
Somethings []Something `json:"something"`
}
raw, err := client.ExecRaw(ctx, query, map[string]any{})
if err != nil {
panic(err)
}
err = json.Unmarshal(raw, &res)
Breaking change: currently QueryRaw
, MutateRaw
and Subscribe
methods return *json.RawMessage
. This output type is redundant to be decoded. The output type should be changed to []byte
.
var subscription struct {
Me struct {
Name graphql.String
}
}
subscriptionId, err := client.Subscribe(&query, nil, func(dataValue []byte, errValue error) error {
if errValue != nil {
// handle error
// if returns error, it will failback to `onError` event
return nil
}
data := query{}
err := json.Unmarshal(dataValue, &data)
fmt.Println(query.Me.Name)
// Output: Luke Skywalker
return nil
})
if err != nil {
// Handle error.
}