{"id":13508521,"url":"https://github.com/jungsoft/crudry","last_synced_at":"2025-04-07T16:18:27.866Z","repository":{"id":44674796,"uuid":"161695486","full_name":"jungsoft/crudry","owner":"jungsoft","description":"Elixir library for DRYing CRUD in Phoenix Contexts and Absinthe Resolvers.","archived":false,"fork":false,"pushed_at":"2022-01-31T19:09:11.000Z","size":179,"stargazers_count":90,"open_issues_count":5,"forks_count":11,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-08-19T15:48:44.129Z","etag":null,"topics":["elixir"],"latest_commit_sha":null,"homepage":"https://hexdocs.pm/crudry","language":"Elixir","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/jungsoft.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":"2018-12-13T21:13:04.000Z","updated_at":"2024-03-15T21:38:17.000Z","dependencies_parsed_at":"2022-09-07T05:31:46.994Z","dependency_job_id":null,"html_url":"https://github.com/jungsoft/crudry","commit_stats":null,"previous_names":["gabrielpra1/crudry"],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jungsoft%2Fcrudry","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jungsoft%2Fcrudry/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jungsoft%2Fcrudry/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jungsoft%2Fcrudry/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jungsoft","download_url":"https://codeload.github.com/jungsoft/crudry/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247685628,"owners_count":20979085,"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":["elixir"],"created_at":"2024-08-01T02:00:54.308Z","updated_at":"2025-04-07T16:18:27.848Z","avatar_url":"https://github.com/jungsoft.png","language":"Elixir","funding_links":[],"categories":["Macros","Running the update"],"sub_categories":["By Popularity"],"readme":"![Crudry](img/crudry.svg)\n\n[![Coverage Status](https://coveralls.io/repos/github/jungsoft/crudry/badge.svg?branch=master)](https://coveralls.io/github/jungsoft/crudry?branch=master)\n\nCrudry is an elixir library for DRYing CRUD of Phoenix Contexts and Absinthe Resolvers.\n\nIt also provides a simple middleware for translating changeset errors into readable messages.\n\nDocumentation can be found at [https://hexdocs.pm/crudry](https://hexdocs.pm/crudry).\n\nThe changelog can be found at the [Releases page](https://github.com/jungsoft/crudry/releases).\n\n## Installation\n\nThe package can be installed by adding `crudry` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:crudry, \"~\u003e 2.4.0\"},\n  ]\nend\n```\n\n## Usage\n\n### Context Generation\n\nTo generate CRUD functions for a given schema in your context, simply do:\n\n```elixir\ndefmodule MyApp.MyContext do\n  alias MyApp.Repo\n\n  require Crudry.Context\n  Crudry.Context.generate_functions MyApp.MySchema\nend\n```\n\nTo see the functions that are generated and custom options, refer to the [Crudry.Context docs](https://hexdocs.pm/crudry/Crudry.Context.html#module-usage).\n\n\n### Resolver Generation\n\nWith the context all set up, the resolver is ready to be generated:\n\n```elixir\ndefmodule MyApp.MyResolver do\n  alias MyApp.Repo\n\n  require Crudry.Resolver\n  Crudry.Resolver.generate_functions MyApp.MyContext, MyApp.MySchema\nend\n```\n\nTo see the functions that are generated and custom options, refer to the [Crudry.Resolver docs](https://hexdocs.pm/crudry/Crudry.Resolver.html#module-usage).\n\n### Translate Errors middleware\n\nAbsinthe Middleware to translate errors and changeset errors into human readable messages. It support nested changeset errors and internationalization, using [Gettext](https://github.com/elixir-lang/gettext).\n\nTo handle errors for a field, add it after the resolve, using [`middleware/2`](https://hexdocs.pm/absinthe/Absinthe.Middleware.html#module-the-middleware-2-macro):\n\n```elixir\nalias Crudry.Middlewares.TranslateErrors\n\nfield :create_user, :user do\n  arg :params, non_null(:user_params)\n\n  resolve \u0026UsersResolver.create_user/2\n  middleware TranslateErrors\nend\n```\n\nTo handle errors for all fields, use [middleware/3](https://hexdocs.pm/absinthe/Absinthe.Middleware.html#module-object-wide-authentication):\n\n```elixir\nalias Crudry.Middlewares.TranslateErrors\n\ndef middleware(middleware, _field, _object) do\n  middleware ++ [TranslateErrors]\nend\n```\n\n`Crudry.Translator` is used by default to translate error messages to the default locale `en`. You can also use your own Gettext module by adding it to your Absinthe's schema `context/1` function:\n\n```elixir\ndef context(context) do\n  Map.put(context, :translator, MyAppWeb.Gettext)\nend\n```\n\nOr just override the default locale in your [Context Plug](https://hexdocs.pm/absinthe/context-and-authentication.html#context-and-plugs):\n\n```elixir\ndef call(conn, _) do\n  Absinthe.Plug.put_options(conn, context: %{locale: \"pt_BR\"})\nend\n```\n\nRefer to the [TranslateErrors docs](https://hexdocs.pm/crudry/Crudry.Middlewares.TranslateErrors.html) for more information.\n\n## Related Projects\n\n* [Rajska](https://github.com/jungsoft/rajska) is an elixir authorization library for Absinthe.\n* [Uploadex](https://github.com/jungsoft/uploadex) is an elixir library for handling uploads using Ecto and Arc\n\n## License\n\nMIT License.\n\nSee [LICENSE](./LICENSE) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjungsoft%2Fcrudry","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjungsoft%2Fcrudry","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjungsoft%2Fcrudry/lists"}