{"id":13878505,"url":"https://github.com/coleturner/graphql-rails-activereflection","last_synced_at":"2026-05-03T11:32:16.061Z","repository":{"id":87694531,"uuid":"88467523","full_name":"coleturner/graphql-rails-activereflection","owner":"coleturner","description":"Reflection over GraphQL for ActiveRecord models and validators","archived":false,"fork":false,"pushed_at":"2017-05-21T20:49:15.000Z","size":17,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-28T00:22:49.082Z","etag":null,"topics":["activerecord","graphql","rails","ruby","validators"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","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/coleturner.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"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}},"created_at":"2017-04-17T04:18:13.000Z","updated_at":"2022-06-03T10:31:41.000Z","dependencies_parsed_at":null,"dependency_job_id":"4f16d436-ffb1-44c6-b5b9-0ae7ac1a33cc","html_url":"https://github.com/coleturner/graphql-rails-activereflection","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/coleturner/graphql-rails-activereflection","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coleturner%2Fgraphql-rails-activereflection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coleturner%2Fgraphql-rails-activereflection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coleturner%2Fgraphql-rails-activereflection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coleturner%2Fgraphql-rails-activereflection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coleturner","download_url":"https://codeload.github.com/coleturner/graphql-rails-activereflection/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coleturner%2Fgraphql-rails-activereflection/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32567210,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-03T06:36:36.687Z","status":"ssl_error","status_checked_at":"2026-05-03T06:36:09.306Z","response_time":103,"last_error":"SSL_read: 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":["activerecord","graphql","rails","ruby","validators"],"created_at":"2024-08-06T08:01:51.703Z","updated_at":"2026-05-03T11:32:16.056Z","avatar_url":"https://github.com/coleturner.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# GraphQL::Rails::ActiveReflection\n## (graphql-rails-activereflection)\nReflection over GraphQL for ActiveRecord models and validators\n\n# What is it?\nThe purpose of this gem is to enable ActiveRecord reflections on models over GraphQL.\n\nAt release, this gem only contains reflections on validators. This is to avoid duplication and doubling up on the front-end for how to validate form inputs.\n\nEventually I would like to include some React examples and sample container components to apply the validators.\n\n# Installation\nTo begin, install the gem by adding it to the `Gemfile`:\n\n```ruby\n  gem 'graphql-rails-activereflection'\n```\n\nYou're now ready to expose validators for your GraphQL Fields.  This only works for fields that resolve to ActiveRecord Models.\n\nTo expose a field, add the following line:\n\n```ruby\n  implements GraphQL::Rails::ActiveReflection::Model.interface, inherit: true\n```\n\nAnd that's it! This will add a `_model` field to the object type and enables the following query:\n\n```graphql\nfragment on YourObjectType {\n  _model: ActiveReflectionModel {\n    attributes: [ActiveReflectionAttribute] {\n      name: String\n      field_name: String\n\n      validators: [ActiveReflectionValidator] {\n        absence: Boolean\n        presence: Boolean\n        uniqueness: Boolean\n        with_format: String\n        without_format: String\n        min_length: Integer\n        max_length: Integer\n        inclusion: [String]\n        exclusion: [String]\n      }\n\n      validate(int: Integer, str: String, float: Float, bool: Boolean): ActiveReflectionValidation {\n        valid: Boolean\n        errors: [String]\n      }\n    }\n  }\n}\n```\n\nThe `_model` field will resolve to whatever type `Schema.resolve_type` returns for that object.\nOnly the fields on that type will be exposed as `attributes` - where `name` is the attribute name and `field_name` is the field name that exposed the attribute.\n\nEach of the validators corresponds to the standard Rails validators. Almost all validators for an attribute will be returned, **except those that have the `if` or `unless` conditionals.** This is by design and therefore make note that any conditional validations will have to be performed manually.\n\nThere is also the `validate(...)` field with arguments for standard scalar types. Any one of the arguments can be provided, but only one. The result will contain a `valid` boolean and a list of `errors` strings returned from the validators.\n\nIn the future all of the `validate(...)` should be chained for a single call.\n\n## Direction\nFuture plans for this module are to expose any reflections for an ActiveRecord model.\n\n# Needs Help\nIf you wish to contribute to this project, any pull request is warmly welcomed.\n\n- [ ] Documentation\n- [ ] Examples\n- [ ] Unit Tests\n- [ ] Merge `validate(...)` calls\n\n# Credits\n- Cole Turner ([@colepatrickturner](https://github.com/colepatrickturner))\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoleturner%2Fgraphql-rails-activereflection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoleturner%2Fgraphql-rails-activereflection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoleturner%2Fgraphql-rails-activereflection/lists"}