{"id":13490126,"url":"https://github.com/Khan/genqlient","last_synced_at":"2025-03-28T05:31:58.364Z","repository":{"id":37077239,"uuid":"234450184","full_name":"Khan/genqlient","owner":"Khan","description":"a truly type-safe Go GraphQL client","archived":false,"fork":false,"pushed_at":"2025-02-03T00:20:53.000Z","size":1444,"stargazers_count":1172,"open_issues_count":58,"forks_count":119,"subscribers_count":51,"default_branch":"main","last_synced_at":"2025-03-26T17:09:58.115Z","etag":null,"topics":["codegen","go","golang","graphql"],"latest_commit_sha":null,"homepage":"","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/Khan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"docs/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"docs/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":"docs/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-01-17T02:01:49.000Z","updated_at":"2025-03-26T09:30:09.000Z","dependencies_parsed_at":"2024-02-15T04:26:41.588Z","dependency_job_id":"1a8d56ae-a6ee-4fe9-87bc-af37e359c96b","html_url":"https://github.com/Khan/genqlient","commit_stats":{"total_commits":295,"total_committers":28,"mean_commits":"10.535714285714286","dds":"0.30847457627118646","last_synced_commit":"3da9a0f905b39f3b74156cb47d892543e5ab40aa"},"previous_names":["khan/genql"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Khan%2Fgenqlient","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Khan%2Fgenqlient/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Khan%2Fgenqlient/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Khan%2Fgenqlient/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Khan","download_url":"https://codeload.github.com/Khan/genqlient/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245978200,"owners_count":20703675,"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":["codegen","go","golang","graphql"],"created_at":"2024-07-31T19:00:41.216Z","updated_at":"2025-03-28T05:31:57.958Z","avatar_url":"https://github.com/Khan.png","language":"Go","funding_links":[],"categories":["Go","Repositories"],"sub_categories":[],"readme":"\u003cimg width=\"100%\" alt=\"generated graphql client ⇒ genqlient\" src=\"docs/images/genqlient.svg\"\u003e\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/Khan/genqlient.svg)](https://pkg.go.dev/github.com/Khan/genqlient)\n[![Test Status](https://github.com/Khan/genqlient/actions/workflows/go.yml/badge.svg)](https://github.com/Khan/genqlient/actions)\n[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](docs/CODE_OF_CONDUCT.md)\n[![GoReportcard](https://goreportcard.com/badge/github.com/Khan/genqlient?status.svg)](https://goreportcard.com/report/github.com/Khan/genqlient)\n\n# genqlient: a truly type-safe Go GraphQL client\n\n## What is genqlient?\n\ngenqlient is a Go library to easily generate type-safe code to query a GraphQL API. It takes advantage of the fact that both GraphQL and Go are typed languages to ensure at compile-time that your code is making a valid GraphQL query and using the result correctly, all with a minimum of boilerplate.\n\ngenqlient provides:\n\n- Compile-time validation of GraphQL queries: never ship an invalid GraphQL query again!\n- Type-safe response objects: genqlient generates the right type for each query, so you know the response will unmarshal correctly and never need to use `interface{}`.\n- Production-readiness: genqlient is used in production at Khan Academy, where it supports millions of learners and teachers around the world.\n\n## How do I use genqlient?\n\nYou can download and run genqlient the usual way: `go run github.com/Khan/genqlient`.  To set your project up to use genqlient, see the [getting started guide](docs/introduction.md), or the [example](example).  For more complete documentation, see the [docs](docs).\n\n## How can I help?\n\ngenqlient welcomes contributions!  Check out the ([Contribution Guidelines](docs/CONTRIBUTING.md)), or file an issue [on GitHub](issues).\n\n## Why another GraphQL client?\n\nMost common Go GraphQL clients have you write code something like this:\n```go\nquery := `query GetUser($id: ID!) { user(id: $id) { name } }`\nvariables := map[string]interface{}{\"id\": \"123\"}\nvar resp struct {\n\tMe struct {\n\t\tName graphql.String\n\t}\n}\nclient.Query(ctx, query, \u0026resp, variables)\nfmt.Println(resp.Me.Name)\n// Output: Luke Skywalker\n```\n\nThis code works, but it has a few problems:\n\n- While the response struct is type-safe at the Go level; there's nothing to check that the schema looks like you expect.  Maybe the field is called `fullName`, not `name`; or maybe you capitalized it wrong (since Go and GraphQL have different conventions); you won't know until runtime.\n- The GraphQL variables aren't type-safe at all; you could have passed `{\"id\": true}` and again you won't know until runtime!\n- You have to write everything twice, or hide the query in complicated struct tags, or give up what type safety you do have and resort to `interface{}`.\n\nThese problems aren't a big deal in a small application, but for serious production-grade tools they're not ideal.  And they should be entirely avoidable: GraphQL and Go are both typed languages; and GraphQL servers expose their schema in a standard, machine-readable format.  We should be able to simply write a query and have that automatically validated against the schema and turned into a Go struct which we can use in our code.  In fact, there's already good prior art to do this sort of thing: [99designs/gqlgen](https://github.com/99designs/gqlgen) is a popular server library that generates types, and Apollo has a [codegen tool](https://www.apollographql.com/docs/devtools/cli/#supported-commands) to generate similar client-types for several other languages.  (See the [design note](docs/design.md) for more prior art.)\n\ngenqlient fills that gap: you just specify the query, and it generates type-safe helpers, validated against the schema, that make the query.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FKhan%2Fgenqlient","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FKhan%2Fgenqlient","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FKhan%2Fgenqlient/lists"}