Typed Go client for the FrameWorks GraphQL API: a generated function for every public root field and argument-taking field, plus retries, typed errors, a server version check, pagination, subscriptions, VOD uploads, playback token signing, and webhook verification.
go get github.com/Livepeer-FrameWorks/sdk-goclient, err := frameworks.NewClient(frameworks.ClientOptions{
URL: "https://bridge.example.com/graphql",
Token: apiToken,
})
if err != nil {
log.Fatal(err)
}
resp, err := frameworks.CreateStream(ctx, client, frameworks.CreateStreamInput{Name: "launch-event"})
if err != nil {
log.Fatal(err)
}
stream, err := frameworks.ExpectResult[*frameworks.CreateStreamCreateStream](resp.CreateStream)More examples are in examples/; the guide is at
https://logbook.frameworks.network/builders/sdks.
Every public root field and argument-taking field has a generated function
with a default selection. For other selections, write your own operation
documents against the public schema,
pkg/graphql/public/schema.public.graphql,
and generate typed functions with genqlient
in your own module, binding the custom scalars as the SDK does:
# genqlient.yaml
schema: schema.public.graphql
operations: [operations/*.graphql]
generated: frameworksops/generated.go
package: frameworksops
bindings:
Time: { type: time.Time }
JSON: { type: encoding/json.RawMessage }
Currency: { type: string }
Money: { type: string }*frameworks.Client implements genqlient's graphql.Client, so the generated
functions take it directly and run through MakeRequest: the same
authentication, retries, typed errors, and server version check as the SDK's
own functions. A document can also be sent without code generation:
var data struct {
Stream *struct {
Name string `json:"name"`
} `json:"stream"`
}
err := client.MakeRequest(ctx, &graphql.Request{
Query: `query StreamName($id: ID!) { stream(id: $id) { name } }`,
OpName: "StreamName",
Variables: map[string]any{"id": streamID},
}, &graphql.Response{Data: &data})MakeRequest runs queries and mutations; subscriptions use a
SubscriptionClient. Give custom operations names of your own: the server
version check looks up an SDK operation's release by its name.
The TypeScript, Go, and Python SDKs share one version. Before 1.0 each minor
version is its own compatibility line, and MinServerVersion is the oldest
FrameWorks release the line supports; against an older server every call
returns *ServerTooOldError.
This repository is a mirror of sdk_go/ in
Livepeer-FrameWorks/monorepo;
open issues and pull requests there.