Migrating to graphiti-rails
You can continue using Graphiti 1.0 without this, but the migration is only a few simple steps.
Application Code
First, bump to Graphiti 1.2 - everything should work as-is, but you’ll start seeing deprecation notices.
Then add graphiti-rails
to your Gemfile
:
You’ll see slightly different deprecation notices at this point. To fix:
- Remove
include Graphiti::Rails
fromApplicationController
- Remove
include Graphiti::Responders
fromApplicationController
- Remove the
register_exception
for404
errors if you have one. Keep anything else, but this is now built-in by default. - If you’re using responders, Add
include Graphiti::Rails::Responders
fromApplicationController
. - Remove the
rescue_from
block.
Finally, if you were passing the show_raw_error
option to
#handle_exception
, replace this with #show_detailed_exceptions?
:
Keep in mind, we’ll always show detailed exceptions in development mode, per Rails conventions. If this is confusing or not desirable, set
config.consider_all_requests_local = false
inconfig/environments/development.rb
If you’re not running Rails in API-only mode, be sure to set
config.debug_exception_response_format = :api
inconfig/application.rb
Testing
Add config.include Graphiti::Rails::TestHelpers
to
spec/rails_helper.rb
.
Replace
With
Change any calls to GraphitiErrors.enable!/disable!
with
handle_request_exceptions(true|false)
.