{"id":17592377,"url":"https://github.com/gastonmorixe/rails-fields","last_synced_at":"2025-04-13T18:14:50.815Z","repository":{"id":190918850,"uuid":"683584317","full_name":"gastonmorixe/rails-fields","owner":"gastonmorixe","description":"📝 Declarative fields for Rails ActiveRecord models 🚀 automatic migrations and 🦄  graphql types generation!","archived":false,"fork":false,"pushed_at":"2024-05-11T18:36:16.000Z","size":427,"stargazers_count":12,"open_issues_count":12,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-13T18:14:48.571Z","etag":null,"topics":["activerecord","graphql","rails","ruby"],"latest_commit_sha":null,"homepage":"https://rails-fields.dev","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/gastonmorixe.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":"CODE_OF_CONDUCT.md","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},"funding":{"github":["gastonmorixe"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2023-08-27T03:39:13.000Z","updated_at":"2025-01-14T17:19:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"f1f64c37-52ce-422e-a714-c3ddad5d1423","html_url":"https://github.com/gastonmorixe/rails-fields","commit_stats":{"total_commits":50,"total_committers":1,"mean_commits":50.0,"dds":0.0,"last_synced_commit":"2aead55f59548a0063ab1ad38856c0554e1c5393"},"previous_names":["gastonmorixe/rails-fields"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gastonmorixe%2Frails-fields","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gastonmorixe%2Frails-fields/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gastonmorixe%2Frails-fields/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gastonmorixe%2Frails-fields/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gastonmorixe","download_url":"https://codeload.github.com/gastonmorixe/rails-fields/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248758418,"owners_count":21156957,"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":["activerecord","graphql","rails","ruby"],"created_at":"2024-10-22T05:10:29.460Z","updated_at":"2025-04-13T18:14:50.792Z","avatar_url":"https://github.com/gastonmorixe.png","language":"Ruby","funding_links":["https://github.com/sponsors/gastonmorixe"],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://rails-fields.dev\" target=\"_blank\"\u003e\u003cimg src=\"./assets/logo.svg\" width=\"300\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n[![Gem Version](https://badge.fury.io/rb/rails-fields.svg?v=320)](https://badge.fury.io/rb/rails-fields)\n\n# Rails Fields\n\nEnforce field types and attributes for ActiveRecord models in Ruby on Rails applications.\n\n- 🚀 Automatic ActiveRecord **Migrations** generation\n- 🦄 Automatic [GraphQL types](https://graphql-ruby.org/type_definitions/objects.html) generation\n- 📝 Explicit **declarative** model attributes annotation\n- 💪🏻 Enforcement of fields declaration with real db columns\n- 📜 Automatic YARD model documentation\n\n## Description\nThe `rails-fields` gem provides robust field type enforcement for ActiveRecord models in Ruby on Rails applications. It includes utility methods for type validation, logging, and field mappings between GraphQL and ActiveRecord types. Custom error classes provide clear diagnostics for field-related issues, making it easier to maintain consistent data models.\n\n## Usage\n\nIn your ActiveRecord models:\n\n```ruby\nclass User \u003c ApplicationRecord\n  field :id, :integer\n  field :created_at, :datetime\n  field :updated_at, :datetime\n\n  field :first_name, :string\n  field :country, :string\n  field :welcome, :string\n\n  has_many :todos\n  \n  def welcome\n    \"Welcome #{first_name}!\"\n  end\nend\n```\n\nAutogenerate GraphQL types using `#gql_type` class method:\n\n```ruby\nmodule Types\n  class QueryType \u003c Types::BaseObject\n    \n    field :users, [User.gql_type], null: true\n    \n    def users\n      User.all\n    end\n    \n  end\nend\n```\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'rails-fields'\n```\n\nIf you want to have graphql types generated for your models, add this line to your application's Gemfile:\n\n```ruby\ngem 'graphql'\n```\n\n*Don't forget to install it `$ ./bin/rails generate graphql:install`*\n\nAnd then execute:\n\n```bash\n$ bundle install\n```\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n## Author\n\nGaston Morixe 2023 - gaston@gastonmorixe.com\n\n[rails-fields.dev](https://rails-fields.dev/?gh)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgastonmorixe%2Frails-fields","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgastonmorixe%2Frails-fields","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgastonmorixe%2Frails-fields/lists"}