{"id":15020063,"url":"https://github.com/polyvariant/smithy4s-caliban","last_synced_at":"2025-10-25T00:30:41.124Z","repository":{"id":171133415,"uuid":"647486949","full_name":"polyvariant/smithy4s-caliban","owner":"polyvariant","description":"Smithy4s integration for Caliban, a Scala GraphQL library.","archived":false,"fork":false,"pushed_at":"2023-10-22T16:40:31.000Z","size":77,"stargazers_count":15,"open_issues_count":3,"forks_count":0,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-01-31T04:32:02.330Z","etag":null,"topics":["caliban","graphql","graphql-server","scala","smithy","smithy4s"],"latest_commit_sha":null,"homepage":"","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/polyvariant.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-05-30T22:22:49.000Z","updated_at":"2023-10-18T12:01:49.000Z","dependencies_parsed_at":null,"dependency_job_id":"8cac3ff7-45fd-4096-9cb0-300564ee75cb","html_url":"https://github.com/polyvariant/smithy4s-caliban","commit_stats":null,"previous_names":["polyvariant/smithy4s-caliban"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/polyvariant%2Fsmithy4s-caliban","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/polyvariant%2Fsmithy4s-caliban/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/polyvariant%2Fsmithy4s-caliban/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/polyvariant%2Fsmithy4s-caliban/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/polyvariant","download_url":"https://codeload.github.com/polyvariant/smithy4s-caliban/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238046845,"owners_count":19407625,"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":["caliban","graphql","graphql-server","scala","smithy","smithy4s"],"created_at":"2024-09-24T19:54:32.308Z","updated_at":"2025-10-25T00:30:40.724Z","avatar_url":"https://github.com/polyvariant.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"# smithy4s-caliban\n\n[Smithy4s](https://disneystreaming.github.io/smithy4s/) integration for [Caliban](https://ghostdogpr.github.io/caliban/).\n\n## Installation\n\nIn sbt:\n\n```scala\nlibraryDependencies ++= Seq(\"org.polyvariant\" %% \"smithy4s-caliban\" % version)\n```\n\nIn scala-cli:\n\n```\n//\u003e using lib \"org.polyvariant::smithy4s-caliban:version\"\n```\n\n## Usage\n\n### Set up smithy4s\n\nFollow the [quickstart steps](https://disneystreaming.github.io/smithy4s/docs/overview/quickstart).\n\n### Write a Smithy spec\n\nFor example:\n\n\u003c!-- Development note - this snippet should be kept in sync with hello.smithy in `modules/docs` --\u003e\n\n```smithy\n$version: \"2\"\n\nnamespace hello\n\nservice HelloService {\n    operations: [GetHello]\n}\n\n@readonly\noperation GetHello {\n    input := {\n        @required\n        name: String\n    }\n    output := {\n        @required\n        greeting: String\n    }\n}\n\n```\n\nMake sure you can generate Smithy4s code for that spec.\n\n### Implement service\n\nImplement the trait generated by Smithy4s:\n\n```scala mdoc\nimport hello._\nimport cats.effect._\n\nval impl: HelloService[IO] = new HelloService[IO] {\n  override def getHello(name: String): IO[GetHelloOutput] =\n    IO.println(\"hello, \" + name).as(GetHelloOutput(\"hello, \" + name))\n}\n```\n\n### Interpret to GraphQL\n\nThis is what the library will allow you to do: convert that service implementation to a GraphQL root.\n\n```scala mdoc\nimport org.polyvariant.smithy4scaliban._\nimport caliban.GraphQL\n\nval api: Resource[IO, GraphQL[Any]] = CalibanGraphQLInterpreter.server(impl)\n```\n\nThis returns a Resource because it requires (and creates) a `Dispatcher`.\n\nNow, the last part - you have to connect this GraphQL instance to a server. How you do it is up to you, but [http4s](https://ghostdogpr.github.io/caliban/docs/adapters.html#json-handling) is recommended. Here's a full example (requires `caliban-http4s`, `tapir-json-circe` and `http4s-ember-server`):\n\n```scala mdoc\nimport caliban.Http4sAdapter\nimport caliban.CalibanError\nimport caliban.interop.tapir.HttpInterpreter\nimport sttp.tapir.json.circe._\nimport caliban.interop.cats.implicits._\nimport org.http4s.ember.server.EmberServerBuilder\n\nval server: IO[Nothing] = api.evalMap { serverApi =\u003e\n  implicit val rt: zio.Runtime[Any] = zio.Runtime.default\n\n  serverApi\n    .interpreterAsync[IO]\n    .map { interp =\u003e\n      Http4sAdapter.makeHttpServiceF[IO, Any, CalibanError](HttpInterpreter(interp))\n    }\n}\n.flatMap { routes =\u003e\n  EmberServerBuilder.default[IO].withHttpApp(routes.orNotFound).build\n}.useForever\n```\n\nThis will launch a server on `localhost:8080` running your Smithy spec as a GraphQL API.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpolyvariant%2Fsmithy4s-caliban","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpolyvariant%2Fsmithy4s-caliban","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpolyvariant%2Fsmithy4s-caliban/lists"}