All Projects → exAspArk → Graphql Errors

exAspArk / Graphql Errors

Licence: mit
Simple error handler for GraphQL Ruby ❗️

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Graphql Errors

Thoth
An Error Logger for Go
Stars: ✭ 22 (-87.06%)
Mutual labels:  error-handling, error
Extensible Custom Error
JavaScript extensible custom error that can take a message and/or an Error object
Stars: ✭ 64 (-62.35%)
Mutual labels:  error-handling, error
Make Error Cause
Make your own nested errors
Stars: ✭ 36 (-78.82%)
Mutual labels:  error-handling, error
Traceback with variables
Adds variables to python traceback. Simple, lightweight, controllable. Debug reasons of exceptions by logging or pretty printing colorful variable contexts for each frame in a stacktrace, showing every value. Dump locals environments after errors to console, files, and loggers. Works in Jupyter and IPython. Install with pip or conda.
Stars: ✭ 509 (+199.41%)
Mutual labels:  error-handling, exception-handling
Production Ready Expressjs Server
Express.js server that implements production-ready error handling and logging following latest best practices.
Stars: ✭ 101 (-40.59%)
Mutual labels:  graphql, error-handling
Bugsnag Js
Javascript error handling tool for Bugsnag. Monitor and report JavaScript bugs & errors.
Stars: ✭ 625 (+267.65%)
Mutual labels:  error-handling, exception-handling
Go Errortree
Go library for handling errors organized as a tree
Stars: ✭ 59 (-65.29%)
Mutual labels:  error-handling, error
go-errors
Flexible, general-purpose error handling for Go.
Stars: ✭ 17 (-90%)
Mutual labels:  error-handling, error
Faux Pas
A library that simplifies error handling for Functional Programming in Java
Stars: ✭ 100 (-41.18%)
Mutual labels:  error-handling, exception-handling
Apollo Prophecy
🔮 GraphQL error management made Easy, generate custom machine-readable errors for Apollo Client/Server from the CLI
Stars: ✭ 83 (-51.18%)
Mutual labels:  graphql, error-handling
Bugsnag Php
Bugsnag error monitoring and crash reporting tool for PHP apps
Stars: ✭ 475 (+179.41%)
Mutual labels:  error-handling, exception-handling
Framework
Strongly-typed JavaScript object with support for validation and error handling.
Stars: ✭ 136 (-20%)
Mutual labels:  graphql, error-handling
Log Process Errors
Show some ❤️ to Node.js process errors
Stars: ✭ 424 (+149.41%)
Mutual labels:  error-handling, error
Error Overlay Webpack Plugin
Catch errors with style 💥✨
Stars: ✭ 821 (+382.94%)
Mutual labels:  error-handling, error
Bugsnag React Native
Error monitoring and reporting tool for native exceptions and JS errors in React Native apps
Stars: ✭ 374 (+120%)
Mutual labels:  error-handling, exception-handling
Bugsnag Node
[DEPRECATED] Please upgrade to our Universal JS notifier "@bugsnag/js" • https://github.com/bugsnag/bugsnag-js
Stars: ✭ 48 (-71.76%)
Mutual labels:  error-handling, error
ErrorLayout
Simple layout to show custom error toast with animation
Stars: ✭ 13 (-92.35%)
Mutual labels:  error-handling, error
rust-error-handle
detail rust error handle
Stars: ✭ 47 (-72.35%)
Mutual labels:  error-handling, error
Mjn
⚡️Like loadash.get, but in ~200 bytes
Stars: ✭ 69 (-59.41%)
Mutual labels:  error-handling, exception-handling
Stacktracey
Parses call stacks. Reads sources. Clean & filtered output. Sourcemaps. Node & browsers.
Stars: ✭ 115 (-32.35%)
Mutual labels:  error-handling, exception-handling

graphql-errors

⚠️ This gem is deprecated in favor of the new GraphQL::Execution::Errors in the graphql gem. See more details rmosolgo/graphql-ruby#2458.


Build Status Coverage Status Downloads Latest Version

This gem provides a simple error handling for graphql-ruby.

Highlights

  • Error handling for each field.
  • Logic inside the rescue_from block, similarly to Rails.
  • Catching exceptions by ancestors, e.g. CustomError with rescue_from StandardError.
  • Per schema configuration.
  • No dependencies.

Usage

Once you defined your GraphQL schema:

Schema = GraphQL::Schema.define do
  query QueryType
end

You can add rescue_from error handlers with GraphQL::Errors. For example:

GraphQL::Errors.configure(Schema) do
  rescue_from ActiveRecord::RecordNotFound do |exception|
    nil
  end

  rescue_from ActiveRecord::RecordInvalid do |exception|
    GraphQL::ExecutionError.new(exception.record.errors.full_messages.join("\n"))
  end

  # uses Module to handle several similar errors with single rescue_from
  rescue_from MyNetworkErrors do |_|
    GraphQL::ExecutionError.new("Don't mind, just retry the mutation")
  end

  rescue_from StandardError do |exception|
    GraphQL::ExecutionError.new("Please try to execute the query for this field later")
  end

  rescue_from CustomError do |exception, object, arguments, context|
    error = GraphQL::ExecutionError.new("Error found!")
    firstError.path = context.path + ["myError"]
    context.add_error(firstError)
  end
end

It'll handle exceptions raised from each resolver in the schema:

QueryType = GraphQL::ObjectType.define do
  name "Query"

  field :post, PostType do
    argument :id, !types.ID
    resolve ->(obj, args, ctx) { Post.find(args['id']) } # <= will raise ActiveRecord::RecordNotFound
  end
end

Schema.execute('query { post(id: "1") { title } }') # handles the error without failing the whole query
# => { data: { post: nil } }

Installation

Add this line to your application's Gemfile:

gem 'graphql-errors'

And then execute:

$ bundle

Or install it yourself as:

$ gem install graphql-errors

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/exAspArk/graphql-errors. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Graphql::Errors project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].