{"id":37090910,"url":"https://github.com/etix/xdgraph","last_synced_at":"2026-01-14T11:01:12.269Z","repository":{"id":57551158,"uuid":"82076894","full_name":"etix/xdgraph","owner":"etix","description":"Go helper for manipulating Dgraph gRPC responses","archived":true,"fork":false,"pushed_at":"2017-07-11T17:12:13.000Z","size":14,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-06-20T06:24:48.345Z","etag":null,"topics":["dgraph","golang-library","graph-database","grpc"],"latest_commit_sha":null,"homepage":"https://dgraph.io","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/etix.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":"2017-02-15T15:43:37.000Z","updated_at":"2024-06-20T06:24:48.346Z","dependencies_parsed_at":"2022-09-26T18:41:50.659Z","dependency_job_id":null,"html_url":"https://github.com/etix/xdgraph","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/etix/xdgraph","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/etix%2Fxdgraph","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/etix%2Fxdgraph/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/etix%2Fxdgraph/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/etix%2Fxdgraph/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/etix","download_url":"https://codeload.github.com/etix/xdgraph/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/etix%2Fxdgraph/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28417814,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T10:47:48.104Z","status":"ssl_error","status_checked_at":"2026-01-14T10:46:19.031Z","response_time":107,"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":["dgraph","golang-library","graph-database","grpc"],"created_at":"2026-01-14T11:01:11.497Z","updated_at":"2026-01-14T11:01:12.260Z","avatar_url":"https://github.com/etix.png","language":"Go","readme":"# xdgraph: a simple Go helper for manipulating Dgraph gRPC responses\n\n### Installation\n`go get github.com/etix/xdgraph`\n\n### Usage\n```go\npackage main\n\nimport (\n    \"github.com/etix/xdgraph\"\n    \"...\"\n)\n\nint main() {\n    // Set up the gRPC connection\n    conn, err := grpc.Dial(\"127.0.0.1:8080\", grpc.WithInsecure())\n    if err != nil {\n        log.Fatal(err)\n    }\n    defer conn.Close()\n\n    // Initialize the Dgraph gRPC object\n    c := graph.NewDgraphClient(conn)\n    req := client.Req{}\n    req.SetQuery(`\u003cyour query\u003e`)\n\n    // Execute the query and fetch the response\n    resp, err := c.Run(context.Background(), req.Request())\n    if err != nil {\n        log.Fatal(err)\n    }\n\n    // Let's use xdgraph to manipulate the results!\n    xd := xdgraph.ReadResponse(resp)\n\n    // Get the UID of the \"me\" attribute\n    fmt.Println(xd.Attribute(\"me\")..Property(\"_uid_\").ToUid())\n\n    // Get the \"name\" property of the \"me\" attribute\n    fmt.Println(xd.Attribute(\"me\").Property(\"name\").ToString())\n\n    // Skipping the first attribute using First()\n    fmt.Println(xd.First().Property(\"sign\").ToString())\n\n    // Check if a property is set (true/false)\n    fmt.Println(xd.First().Property(\"address\").IsNil())\n\n    // Traverse multiple attributes\n    fmt.Println(xd.First().Attribute(\"follows\").Property(\"name\").ToString())\n\n    // Use different types\n    fmt.Println(xd.First().Attribute(\"follows\").Property(\"birthdate\").ToDate())\n\n    // Execute a function literal for each matched attribute\n    xd.First().Attribute(\"follows\").Attribute(\"plays\").Each(func(r xdgraph.Response) {\n        fmt.Println(r.Property(\"name\").ToString())\n    })\n\n    // Get multiple properties at once\n    for _, sign := range xd.First().Attribute(\"follows\").Properties(\"sign\") {\n        fmt.Println(sign.ToString())\n    }\n\n    // Output the full graph in JSON\n    fmt.Println(xd.Json())\n\n    // Output a sub-graph in JSON\n    fmt.Println(xd.First().Attribute(\"follows\").Json())\n}\n```\nSee the example folder for a complete working example.\n\n### Supported property types\n[See here](https://github.com/dgraph-io/dgraph/blob/master/query/graph/graphresponse.pb.go) for the list of supported types upstream.\n\n| Type        |                            |\n| ----------- | -------------------------- |\n| string      | .ToString()                |\n| []byte      | .ToBytes()                 |\n| int64       | .ToInt()                   |\n| bool        | .ToBool()                  |\n| float64     | .ToFloat()                 |\n| geom        | .ToGeo()                   |\n| datetime    | .ToDate() or .ToDateTime() |\n| uid         | .ToUid()                   |\n\n### Note\nSince the [Dgraph](https://github.com/dgraph-io/dgraph/) project is quite young, the APIs can change at any time.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fetix%2Fxdgraph","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fetix%2Fxdgraph","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fetix%2Fxdgraph/lists"}