{"id":15192305,"url":"https://github.com/solid-wang/graphqlc","last_synced_at":"2026-01-31T15:34:00.875Z","repository":{"id":177793852,"uuid":"660920191","full_name":"solid-wang/graphqlc","owner":"solid-wang","description":"simple go graphql client","archived":false,"fork":false,"pushed_at":"2023-07-03T01:42:04.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-07T14:43:20.116Z","etag":null,"topics":["client","go","graphql","graphql-client"],"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/solid-wang.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":"2023-07-01T08:12:09.000Z","updated_at":"2023-07-02T10:04:10.000Z","dependencies_parsed_at":null,"dependency_job_id":"875bed1b-5a4e-4e7d-9225-dbd1437d4b2c","html_url":"https://github.com/solid-wang/graphqlc","commit_stats":{"total_commits":5,"total_committers":1,"mean_commits":5.0,"dds":0.0,"last_synced_commit":"e49e13fdab84940576df27f214f10e8a5a53361d"},"previous_names":["solid-wang/graphqlc"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/solid-wang/graphqlc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solid-wang%2Fgraphqlc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solid-wang%2Fgraphqlc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solid-wang%2Fgraphqlc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solid-wang%2Fgraphqlc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/solid-wang","download_url":"https://codeload.github.com/solid-wang/graphqlc/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solid-wang%2Fgraphqlc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28946778,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-31T14:26:55.697Z","status":"ssl_error","status_checked_at":"2026-01-31T14:26:52.545Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":["client","go","graphql","graphql-client"],"created_at":"2024-09-27T21:21:29.541Z","updated_at":"2026-01-31T15:34:00.862Z","avatar_url":"https://github.com/solid-wang.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"graphqlc\n=======\n\nPackage `graphqlc` provides a GraphQL client implementation.\n\n- [graphqlc](#graphqlc)\n    - [Installation](#installation)\n    - [Usage](#usage)\n        - [Query](#query)\n          - [Simple Query](#simple-query)\n          - [Arguments and Variables](#arguments-and-variables)\n        - [Mutations](#mutations)\n        - [Subscription](#subscription)\n\n## Installation\n\n```bash\ngo get -u github.com/solid-wang/graphqlc\n```\n\n## Usage\n\nConstruct a GraphQL client, specifying the GraphQL server URL. Then, you can use it to make GraphQL queries、 mutations and subscription.\n\n```Go\nclient, _ := graphqlc.NewClient(\"https://example.com/graphql\")\n// Use client...\n```\n\n### Query\n\n#### Simple Query\n\nFor example, to make the following GraphQL query:\n\n```GraphQL\nquery {\n\tme {\n\t\tname\n\t}\n}\n```\n\nYou can define this graphql request:\n\n```Go\nreq := NewGraphRequest(`\n    query Me {\n        me {\n            name\n        }\n    }\n`, nil)\n```\n\nYou also need to define the struct：\n```Go\ntype Me struct {\n    Name          string\n}\ntype Response struct {\n    Me Me\n}\n```\n\nThen do request, you need passing a pointer to resp:\n\n```Go\nvar resp Response\nerr := client.Body(req).QueryOrMutate().Do(context.Background()).Decode(\u0026resp)\nif err != nil {\n\t// Handle error.\n}\nfmt.Println(query.Me.Name)\n\n// Output: Luke Skywalker\n```\n\n#### Arguments and Variables\n\nOften, you'll want to specify arguments on some fields.\n\nFor example, to make the following GraphQL query:\n\n```GraphQL\n{\n\thuman(id: \"1000\") {\n\t\tname\n\t\theight(unit: METER)\n\t}\n}\n```\n\nYou can define this graphql request:\n\n```Go\nreq := NewGraphRequest(`\n    {\n        human(id: \"1000\") {\n            name\n            height(unit: METER)\n        }\n    }\n`, nil)\n```\n\nUsually, you might want to use:\n```Go\nreq := NewGraphRequest(`\n    query Human($id: ID!, $unit: LengthUnit) {\n        human(id: $id) {\n            name\n            height(unit: $unit)\n        }\n    }\n`, map[string]any{\"id\": \"1000\", \"unit\": \"METER\"})\n```\n\nYou also need to define the struct：\n```Go\ntype Human struct {\n    Name          string\n\theight          string\n}\ntype Response struct {\n    Human Human\n}\n```\n\nThen do request:\n\n```Go\nvar resp Response\nerr := client.Body(req).QueryOrMutate().Do(context.Background()).Decode(\u0026resp)\nif err != nil {\n\t// Handle error.\n}\nfmt.Println(q.Human.Name)\nfmt.Println(q.Human.Height)\n\n// Output:\n// Luke Skywalker\n// 1.72\n```\n\n### Mutations\n\nMutations often require information that you can only find out by performing a query first. Let's suppose you've already done that.\n\nFor example, to make the following GraphQL mutation:\n\n```GraphQL\nmutation($ep: Episode!, $review: ReviewInput!) {\n\tcreateReview(episode: $ep, review: $review) {\n\t\tstars\n\t\tcommentary\n\t}\n}\nvariables {\n\t\"ep\": \"JEDI\",\n\t\"review\": {\n\t\t\"stars\": 5,\n\t\t\"commentary\": \"This is a great movie!\"\n\t}\n}\n```\n\nYou can define:\n```Go\nreq := NewGraphRequest(`\n    mutation($ep: Episode!, $review: ReviewInput!) {\n        createReview(episode: $ep, review: $review) {\n            stars\n            commentary\n        }\n    }\n`, map[string]any{\"ep\": \"JEDI\", \"review\": map[string]any{\"start\": 5, \"commentary\": \"This is a great movie!\"}})\n```\n\nYou also need to define the struct：\n```Go\ntype CreateReview struct {\n    stars          int\n    commentary     string\n}\ntype Response struct {\n    CreateReview CreateReview\n}\n```\n\nThen do request:\n\n```Go\nvar resp Response\nerr = client.Body(req).QueryOrMutate().Do(context.Background()).Decode(\u0026resp)\nif err != nil {\n\t// Handle error.\n}\nfmt.Printf(\"Created a %v star review: %v\\n\", m.CreateReview.Stars, m.CreateReview.Commentary)\n\n// Output:\n// Created a 5 star review: This is a great movie!\n```\n\n### Subscription\n\nFor example, to make the following GraphQL query:\n\n```GraphQL\nsubscription {\n\tme {\n\t\tname\n\t}\n}\n```\n\nYou can define this graphql request:\n\n```Go\nreq := NewGraphRequest(`\n    subscription {\n        me {\n            name\n        }\n    }\n`, nil)\n```\n\nYou also need to define the struct：\n```Go\ntype Me struct {\n    Name          string\n}\ntype Response struct {\n    Me Me\n}\n```\n\nThen run subscribe, passing a pointer to it:\n\n```Go\nsubscribe := client.Body(req).Subscription()\ngo subscribe.Run(context.Background())\ndefer subscribe.Stop()\nfor {\n    decoder := \u003c-subscribe.ResultChan()\n    var resp Response\n    err := decoder.Decode(\u0026resp)\n    if err != nil {\n        // Handle error.\n    return\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsolid-wang%2Fgraphqlc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsolid-wang%2Fgraphqlc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsolid-wang%2Fgraphqlc/lists"}