{"id":13879213,"url":"https://github.com/emilebosch/graphql-ruby-microservices","last_synced_at":"2025-04-11T00:04:56.374Z","repository":{"id":39694499,"uuid":"157992830","full_name":"emilebosch/graphql-ruby-microservices","owner":"emilebosch","description":"Simple POC of microservices with ruby example and graphql","archived":false,"fork":false,"pushed_at":"2023-03-16T06:06:35.000Z","size":18,"stargazers_count":7,"open_issues_count":2,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-11T00:04:48.443Z","etag":null,"topics":["drb","graphql","microservices","ruby"],"latest_commit_sha":null,"homepage":"http://emile.wtf/2019/08/02/the-simplest-ruby-graphql-microservice-setup/","language":"Ruby","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/emilebosch.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}},"created_at":"2018-11-17T14:34:17.000Z","updated_at":"2021-03-12T11:58:56.000Z","dependencies_parsed_at":"2024-01-13T20:57:06.191Z","dependency_job_id":"cf09e6f2-ba78-4b11-8c57-8094248ca139","html_url":"https://github.com/emilebosch/graphql-ruby-microservices","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emilebosch%2Fgraphql-ruby-microservices","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emilebosch%2Fgraphql-ruby-microservices/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emilebosch%2Fgraphql-ruby-microservices/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emilebosch%2Fgraphql-ruby-microservices/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/emilebosch","download_url":"https://codeload.github.com/emilebosch/graphql-ruby-microservices/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248317708,"owners_count":21083528,"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":["drb","graphql","microservices","ruby"],"created_at":"2024-08-06T08:02:13.630Z","updated_at":"2025-04-11T00:04:56.356Z","avatar_url":"https://github.com/emilebosch.png","language":"Ruby","readme":"# Simple Ruby Microservice With Graphql\n\nI would recommend against microservices unless you really really really can't do otherwise. But if you have to, this might be the simplest approach.\n\nThe microservices itself are written in ruby with Distributed Ruby. Meaning you can call easy and fast the underlying microservices without any http layer.\n\nThe setup is as follows:\n\n- User service for fetching users\n- Comment service for fetching comments\n- Graphql service as an umbrella\n\nAll the services run in docker containers for easy building and deployment.\n\nTo run the example:\n\n```sh\ndocker-compose build\ndocker-compose up -d\nopen http://localhost:9292/graphiql\n```\n\nThen query the api:\n\n```graphql\n{\n  users {\n    name\n    comments {\n      text\n    }\n  }\n}\n```\n\nThis is the absolute minimal example.\nThings that you could added:\n\n- Batch loading\n- Automatically eject slow services\n- Reconnecting after downtime of one of the services (this works!)\n- Multiplexing and connection pooling the services (https://github.com/mperham/connection_pool)\n\n## Scenarios:\n\nSimulate a service going down by putting the comment service down.\n\n```\ndocker-compose stop comment_service\n```\n\nAnd query the data again:\n\n```graphql\n{\n  users {\n    name\n    comments {\n      comment\n    }\n  }\n}\n```\n\nYou'll see that you can still query the users but not the comments. The graphql just returns null for the comments. Query the services node to see which of the services is down.\n\nAfter thats put it back up:\n\n```sh\ndocker-compose start comment_service\n```\n\nAfter all that:\n\n```sh\ndocker-compose stop\n```\n\nNotes:\n\n- In case either the comment service dies. It should just return null. This allows for one of the services to go down and the frontend should just be able to deal with that by saying 'comments cant be loaded' instead of exploding on a non-null.\n- Services should be able to be added and scaled up, we can either add a bunch of connections to a connectionpool\n- You might not want to use Drb since it can be a bottleneck and can be quite unsafe. Maybe look at protobuf or another rpc layer.\n- Please microservice responsibly\n","funding_links":[],"categories":["Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femilebosch%2Fgraphql-ruby-microservices","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Femilebosch%2Fgraphql-ruby-microservices","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femilebosch%2Fgraphql-ruby-microservices/lists"}