{"id":13413710,"url":"https://github.com/reaganiwadha/grapher","last_synced_at":"2026-05-13T08:36:17.929Z","repository":{"id":61081127,"uuid":"547674243","full_name":"reaganiwadha/grapher","owner":"reaganiwadha","description":"Neat extra tooling for graphql-go/graphql","archived":false,"fork":false,"pushed_at":"2023-07-21T00:03:40.000Z","size":46,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"trunk","last_synced_at":"2024-07-31T20:52:46.601Z","etag":null,"topics":["go","golang","graphql","graphql-go","graphql-golang"],"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/reaganiwadha.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-10-08T04:32:36.000Z","updated_at":"2023-12-29T06:56:44.000Z","dependencies_parsed_at":"2024-06-21T02:27:06.162Z","dependency_job_id":null,"html_url":"https://github.com/reaganiwadha/grapher","commit_stats":{"total_commits":36,"total_committers":1,"mean_commits":36.0,"dds":0.0,"last_synced_commit":"3e27f57e729abc7d17827cec27a35bacb64962cd"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reaganiwadha%2Fgrapher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reaganiwadha%2Fgrapher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reaganiwadha%2Fgrapher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reaganiwadha%2Fgrapher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/reaganiwadha","download_url":"https://codeload.github.com/reaganiwadha/grapher/tar.gz/refs/heads/trunk","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240595031,"owners_count":19826305,"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-go","graphql-golang"],"created_at":"2024-07-30T20:01:47.065Z","updated_at":"2026-05-13T08:36:17.873Z","avatar_url":"https://github.com/reaganiwadha.png","language":"Go","funding_links":[],"categories":["查询语言","Query Language"],"sub_categories":["HTTP客户端","HTTP Clients"],"readme":"# grapher [![Go Reference](https://pkg.go.dev/badge/github.com/reaganiwadha/grapher.svg)](https://pkg.go.dev/github.com/reaganiwadha/grapher) [![Go Report Card](https://goreportcard.com/badge/github.com/reaganiwadha/grapher)](https://goreportcard.com/report/github.com/reaganiwadha/grapher) [![codecov](https://codecov.io/gh/reaganiwadha/grapher/branch/trunk/graph/badge.svg)](https://codecov.io/gh/reaganiwadha/grapher)\n\nA GraphQL field builder utilizing Go generics with extra utilities and features.\nDepends on [graphql-go](https://github.com/graphql-go/graphql).\n\n## Examples\n### Without grapher\n```go\ntype PostsQuery struct {\n\tLimit int         `json:\"limit\"`\n\tQuery null.String `json:\"query\"`\n\tTags  []string    `json:\"tags\"`\n}\n\ntype Post struct {\n\tID   int    `json:\"id\"`\n\tBody string `json:\"body\"`\n}\n\nfunc buildField() graphql.Fields {\n\treturn graphql.Fields{\n\t\t\"GetPosts\": \u0026graphql.Field{\n\t\t\tDescription : \"Returns posts\",\n\t\t\tType: graphql.NewList(graphql.NewObject(\n\t\t\t\tgraphql.ObjectConfig{\n\t\t\t\t\tName:        \"Post\",\n\t\t\t\t\tFields:      graphql.Fields{\n\t\t\t\t\t\t\"id\" : \u0026graphql.Field{\n\t\t\t\t\t\t\tType: graphql.Int,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"body\" : \u0026graphql.Field{\n\t\t\t\t\t\t\tType: graphql.String,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t)),\n\t\t\tArgs: map[string]*graphql.ArgumentConfig{\n\t\t\t\t\"limit\": {\n\t\t\t\t\tType: graphql.NewNonNull(graphql.Int),\n\t\t\t\t},\n\t\t\t\t\"query\": {\n\t\t\t\t\tType: graphql.String,\n\t\t\t\t},\n\t\t\t\t\"tags\": {\n\t\t\t\t\tType: graphql.NewList(graphql.String),\n\t\t\t\t},\n\t\t\t},\n\t\t\tResolve: func(p graphql.ResolveParams) (ret interface{}, err error) {\n\t\t\t\tvar q PostsQuery\n\t\t\t\tif err = mapstructure.Decode(p.Args, \u0026q); err != nil {\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\t/// resolver logic\n\t\t\t\treturn\n\t\t\t},\n\t\t},\n\t}\n}\n```\n\n### With grapher\n```go\ntype PostsQuery struct {\n\tLimit int         `json:\"limit\"`\n\tQuery null.String `json:\"query\"`\n\tTags  []string    `json:\"tags\"`\n}\n\ntype Post struct {\n\tID   int    `json:\"id\"`\n\tBody string `json:\"body\"`\n}\n\nfunc buildFieldGrapher() graphql.Fields{\n\treturn graphql.Fields{\n\t\t\"GetPosts\" : grapher.NewFieldBuilder[PostsQuery, []Post]().\n\t\t\tWithDescription(\"Returns posts\").\n\t\t\tWithResolver(func(p graphql.ResolveParams, query PostsQuery) (ret []Post, err error) {\n\t\t\t\t// resolver logic\n\t\t\t\treturn \n\t\t\t}).\n\t\t\tMustBuild(),\n\t}\n}\n```\n\n## v1 Development\nThis package is still a work-in-progress. The feature candidates for the v1 release is :\n- [x] Struct to `graphql.Object`/`graphql.InputObject` translator utilizing struct tags\n- [x] Struct to `map[string]*graphql.ArgumentConfig{}`\n- [x] Configurable struct tags translator\n- [x] Schema field builder utilizing go 1.18 Generics feature ensuring type safety\n- [x] Resolver middlewares\n- [x] Resolver arg validator\n- [x] Mux-like schema building with `MutationQueryCollector`\n\nMost features are done, but needs a little bit of polishing.\n\nIf you have any feature ideas, do not hesitate to tell and open a new issue in the Issues tab!\n\n## Contributing\nContributions in any way, shape, or form is super welcomed! If you have any issues, ideas or even a question just open a new issue, or make a pull request. \n\n## License\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freaganiwadha%2Fgrapher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freaganiwadha%2Fgrapher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freaganiwadha%2Fgrapher/lists"}