{"id":13413713,"url":"https://github.com/Zaba505/gws","last_synced_at":"2025-03-14T19:33:02.986Z","repository":{"id":57599527,"uuid":"270805773","full_name":"Zaba505/gws","owner":"Zaba505","description":"A WebSocket client and server for GraphQL","archived":false,"fork":false,"pushed_at":"2020-09-04T06:02:11.000Z","size":92,"stargazers_count":7,"open_issues_count":2,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-07-31T20:52:46.167Z","etag":null,"topics":["go","golang","graphql","graphql-websocket","websockets"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Zaba505.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-06-08T19:51:36.000Z","updated_at":"2023-06-08T02:43:37.000Z","dependencies_parsed_at":"2022-09-26T19:53:23.860Z","dependency_job_id":null,"html_url":"https://github.com/Zaba505/gws","commit_stats":null,"previous_names":["zaba505/graphql-transport-ws"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zaba505%2Fgws","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zaba505%2Fgws/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zaba505%2Fgws/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zaba505%2Fgws/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Zaba505","download_url":"https://codeload.github.com/Zaba505/gws/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243635732,"owners_count":20322985,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","golang","graphql","graphql-websocket","websockets"],"created_at":"2024-07-30T20:01:47.170Z","updated_at":"2025-03-14T19:33:02.683Z","avatar_url":"https://github.com/Zaba505.png","language":"Go","readme":"[![Go Report Card](https://goreportcard.com/badge/github.com/zaba505/gws)](https://goreportcard.com/report/github.com/zaba505/gws)\n[![GoDoc](https://godoc.org/github.com/Zaba505/gws?status.svg)](https://pkg.go.dev/github.com/zaba505/gws?tab=doc)\n[![build](https://github.com/Zaba505/gws/workflows/build/badge.svg)](https://github.com/Zaba505/gws/actions)\n[![codecov](https://codecov.io/gh/Zaba505/gws/branch/master/graph/badge.svg)](https://codecov.io/gh/Zaba505/gws)\n[![Mentioned in Awesome Go](https://awesome.re/mentioned-badge.svg)](https://github.com/avelino/awesome-go)\n\n# gws\nA WebSocket client and server for GraphQL.\n\n`gws` implements Apollos' \"GraphQL over WebSocket\" protocol,\nwhich can be found in PROTOCOL.md. It provides an RPC-like API for both\nclient and server usage.\n\n## Getting Started\n\n`gws` provides both a client and server implementation for the\n\"GraphQL over Websocket\" protocol.\n\n### Client\n\nTo create a client, you must first dial the server like:\n```go\nconn, err := gws.Dial(context.TODO(), \"ws://example.com\")\n// Don't forget to handle the error\n```\n\n`gws.Dial` will return high-level abstraction around the\nunderlying connection. This is very similar to gRPCs'\nbehaviour. After dialing the server, now simply wrap the\nreturn conn and begin performing queries, like:\n```go\nclient := gws.NewClient(conn)\n\nresp, err := client.Query(context.TODO(), \u0026gws.Request{Query: \"{ hello { world } }\"})\n// Don't forget to handle the error\n\nvar data struct{\n  Hello struct{\n    World string\n  }\n}\nerr = json.Unmarshal(resp.Data, \u0026data)\n```\n\n### Server\n\nThe server implementation provided isn't actually a standalone\nserver but instead just a specially configured `http.Handler`.\nThis is because the underlying protocol is simply WebSocket,\nwhich runs on top of HTTP. Creating a bare bones handler is\nas simple as the following:\n```go\nmsgHandler := func(s *Stream, req *Request) error {\n  // Handle request\n  return nil\n}\n\nhttp.ListenAndServe(\":8080\", gws.NewHandler(gws.HandlerFunc(msgHandler)))\n```\n","funding_links":[],"categories":["Query Language","Go语言包管理","查询语言","Relational Databases"],"sub_categories":["HTTP Clients","查询语","HTTP客户端"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FZaba505%2Fgws","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FZaba505%2Fgws","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FZaba505%2Fgws/lists"}