Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bernays/appsyncgo
Go library to easily interact with AWS Appsync backend
https://github.com/bernays/appsyncgo
appsync aws go golang graphql-client mutation query real-time serverless subscriptions
Last synced: 24 days ago
JSON representation
Go library to easily interact with AWS Appsync backend
- Host: GitHub
- URL: https://github.com/bernays/appsyncgo
- Owner: bernays
- License: mit
- Created: 2020-08-25T11:22:26.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2021-07-13T06:11:21.000Z (over 3 years ago)
- Last Synced: 2024-09-30T10:42:47.157Z (about 1 month ago)
- Topics: appsync, aws, go, golang, graphql-client, mutation, query, real-time, serverless, subscriptions
- Language: Go
- Homepage:
- Size: 4.61 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# appsync-go-client
![Go](https://github.com/bernays/appsyncgo/workflows/Go/badge.svg) [![PkgGoDev](https://pkg.go.dev/badge/mod/github.com/bernays/appsyncgo)](https://pkg.go.dev/mod/github.com/bernays/appsyncgo)
This client library is designed to provide a stable interface for programs to interact with AppSync.
It uses native websockets so is able to take advantage of the realtime ability of subscriptions.
Connection recycling and reconnection is built in to handle network issues
## Example:
```
import (
appsync "github.com/bernays/appsyncgo/client"
"github.com/sirupsen/logrus"
"time"
)func HandleData(data string) error {
logger.Printf("Client Side data: %s", data)
return nil
}var logger = logrus.New()
func init() {
logger.SetLevel(logrus.DebugLevel)
}// Can run in main scope or in parallel go routine
func main() {
// default profile will be used to grab credentials and sign reqs
client, err := appsync.CreateClient("https://whom3blq6vhxhd6rkt3offziva.appsync-api.us-east-2.amazonaws.com/graphql", "default")
if err != nil {
logger.Error(err)
}
// Close connection and subscriptions on function end
defer client.CloseConnection(false, false)
client.StartConnection()data := "{\"query\":\"subscription { addedPost{ id title } }\",\"variables\":{}}"
client.Subscribe(data, HandleData)
for {
time.Sleep(2 * time.Second)
}
}
```