{"id":13563553,"url":"https://github.com/graph-gophers/graphql-transport-ws","last_synced_at":"2025-05-05T19:30:39.720Z","repository":{"id":34841737,"uuid":"152343854","full_name":"graph-gophers/graphql-transport-ws","owner":"graph-gophers","description":"WebSocket transport for GraphQL subscriptions","archived":false,"fork":false,"pushed_at":"2022-04-13T11:33:30.000Z","size":48,"stargazers_count":58,"open_issues_count":3,"forks_count":32,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-08-01T13:29:27.990Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/graph-gophers.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":"2018-10-10T01:22:40.000Z","updated_at":"2024-06-23T07:03:12.000Z","dependencies_parsed_at":"2022-08-08T02:01:15.098Z","dependency_job_id":null,"html_url":"https://github.com/graph-gophers/graphql-transport-ws","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graph-gophers%2Fgraphql-transport-ws","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graph-gophers%2Fgraphql-transport-ws/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graph-gophers%2Fgraphql-transport-ws/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graph-gophers%2Fgraphql-transport-ws/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/graph-gophers","download_url":"https://codeload.github.com/graph-gophers/graphql-transport-ws/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223030598,"owners_count":17076462,"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":[],"created_at":"2024-08-01T13:01:20.556Z","updated_at":"2024-11-04T16:30:51.653Z","avatar_url":"https://github.com/graph-gophers.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# graphql-transport-ws\n[![Build Status](https://travis-ci.org/graph-gophers/graphql-transport-ws.svg?branch=master)](https://travis-ci.org/graph-gophers/graphql-transport-ws)\n\n**(Work in progress!)**\n\nA Go package that leverages WebSockets to transport GraphQL subscriptions, queries and mutations implementing the [Apollo@v0.9.4 protocol](https://github.com/apollographql/subscriptions-transport-ws/blob/v0.9.4/PROTOCOL.md)\n\n### Use with graph-gophers/graphql-go\n\nTo use this library with [github.com/graph-gophers/graphql-go](https://github.com/graph-gophers/graphql-go) you can wrap the `relay` handler it provides the following way:\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\n\tgraphql \"github.com/graph-gophers/graphql-go\"\n\t\"github.com/graph-gophers/graphql-go/relay\"\n\t\"github.com/graph-gophers/graphql-transport-ws/graphqlws\"\n)\n\nconst schema = `\n\tschema {\n\t\tsubscription: Subscription\n\t}\n\n\ttype Subscription {\n\t\t...\n\t}\n`\n\ntype resolver struct {\n\t// ...\n}\n\nfunc main() {\n\t// init graphQL schema\n\ts, err := graphql.ParseSchema(schema, \u0026resolver{})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t// graphQL handler\n\tgraphQLHandler := graphqlws.NewHandlerFunc(s, \u0026relay.Handler{Schema: s})\n\thttp.HandleFunc(\"/graphql\", graphQLHandler)\n\n\t// start HTTP server\n\tif err := http.ListenAndServe(fmt.Sprintf(\":%d\", 8080), nil); err != nil {\n\t\tpanic(err)\n\t}\n}\n```\n\nFor a more in depth example see [this repo](https://github.com/matiasanaya/go-graphql-subscription-example).\n\n### Client\n\nCheck [apollographql/subscription-transport-ws](https://github.com/apollographql/subscriptions-transport-ws) for details on how to use WebSockets on the client side.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraph-gophers%2Fgraphql-transport-ws","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgraph-gophers%2Fgraphql-transport-ws","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraph-gophers%2Fgraphql-transport-ws/lists"}