{"id":20239108,"url":"https://github.com/lucasshuan/go-ent-graphql-example","last_synced_at":"2026-02-23T09:03:04.861Z","repository":{"id":209233946,"uuid":"723040023","full_name":"lucasshuan/go-ent-graphql-example","owner":"lucasshuan","description":"Go + ent + gqlgen: A compact API example for GraphQL and database modeling.","archived":false,"fork":false,"pushed_at":"2023-11-29T18:59:58.000Z","size":75,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-27T16:36:52.400Z","etag":null,"topics":["entgo","example","golang","gqlgen"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lucasshuan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2023-11-24T14:34:33.000Z","updated_at":"2024-09-10T19:21:36.000Z","dependencies_parsed_at":"2023-11-29T19:58:51.320Z","dependency_job_id":null,"html_url":"https://github.com/lucasshuan/go-ent-graphql-example","commit_stats":null,"previous_names":["lucasshuan/go-ent-graphql-example"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/lucasshuan/go-ent-graphql-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucasshuan%2Fgo-ent-graphql-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucasshuan%2Fgo-ent-graphql-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucasshuan%2Fgo-ent-graphql-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucasshuan%2Fgo-ent-graphql-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lucasshuan","download_url":"https://codeload.github.com/lucasshuan/go-ent-graphql-example/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucasshuan%2Fgo-ent-graphql-example/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29740738,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-23T07:44:07.782Z","status":"ssl_error","status_checked_at":"2026-02-23T07:44:07.432Z","response_time":90,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["entgo","example","golang","gqlgen"],"created_at":"2024-11-14T08:37:32.960Z","updated_at":"2026-02-23T09:03:04.764Z","avatar_url":"https://github.com/lucasshuan.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cbr\u003e\n\u003cdiv align=\"center\"\u003e\n   \u003cimg src=\"https://github.com/lucasshuan/lucasshuan/assets/78228526/250d306c-c9d7-4b9a-990a-120a8028e881\"\u003e\u003cbr\u003e\n\u003c/div\u003e\n\n## About\n\nThis project serves as an accessible and extensible example and template for a GraphQL server. Its primary goal is to dismiss the often intricate initial setup involved in configuring **ent** (an entity framework) and **gqlgen** (a GraphQL code generator), since once the setup is complete adding new features becomes remarkably straightforward.\n\n## Prerequisites\n\n- **Go**\n- **Docker**\n- **make**\n\n## Getting started\n\n1. Clone the repository:\n\n    ```bash\n    git clone https://github.com/lucasshuan/go-ent-graphql-example.git\n    cd go-ent-graphql-example\n    ```\n\n2. Install dependencies:\n\n    ```bash\n    make deps\n    ```\n\n3. Start Docker containers:\n\n    ```bash\n    make docker-up\n    ```\n\n4. Start the server:\n\n    ```bash\n    make server\n    ```\n\n## Usage\n\nAdding new functionality is fairly simple: To create a new database entity (in this example, we are creating an **Item** entity), just run the following command and enter a name when name input is asked:\n\n\u003cbr\u003e\n\n```bash\nmake entity Item\n```\n\n\u003cbr\u003e\n\nYou will notice that a new file is generated in directory **./ent/schema**. Read more about [Fields](https://entgo.io/docs/schema-fields) and [Edges](https://entgo.io/docs/schema-edges).\n\n\u003cbr\u003e\n\n```go\ntype Item struct {\n    ent.Schema\n}\nfunc (Item) Fields() []ent.Field {\n    return []ent.Field{\n        field.String(\"name\"),\n        field.String(\"description\"),\n    }\n}\n\nfunc (Item) Edges() []ent.Edge {\n    return nil\n}\n```\n\n\u003cbr\u003e\n    \nThe `go generate .` command auto-migrates your database tables for every **./ent/schema/*.go** file. However, at most times, one may want the types generated by ent to be used by the resolvers. This is fairly easy to achieve and also the most important feature of this integration, and the only necessary step is to add an **Annotations** method in your newly created entity file:\n\n\u003cbr\u003e\n\n```go\nfunc (Item) Annotations() []schema.Annotation {\n    return []schema.Annotation{\n        entgql.QueryField(),\n        entgql.Mutations(entgql.MutationCreate(), entgql.MutationUpdate()),\n    }\n}\n```\n\n\u003cbr\u003e\n\nThe code block adds the default queries and mutations to be added to your **./graphql/schema/ent.graphql** schema when running the command `go generate .`. Resolvers will be created in **./graphql/resolvers** directory for each new file, where you will be able to implement all of your queries and mutations.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucasshuan%2Fgo-ent-graphql-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flucasshuan%2Fgo-ent-graphql-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucasshuan%2Fgo-ent-graphql-example/lists"}