Giter Site home page Giter Site logo

Comments (4)

 avatar commented on May 27, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

from graphql-guard.

exAspArk avatar exAspArk commented on May 27, 2024

Hey @sshaw,

Thank you for opening the issue!

with NotAuthorizedError as a superclass one gets proper error response formatting for free, as GraphQL Ruby will insert the exception's message into the "errors" property of the response.

These are 2 different behaviours: either fail the whole request with a Ruby exception (and return a 403 HTTP status, for example) or fail gracefully by returning a response with a GraphQL error. Although both of these use cases are being used, probably returning a GraphQL error is a more popular option (exactly what you suggested). For now, I'd prefer not making this breaking change since there is a way to customize the behaviour.

how do you feel about changing the default message of NotAuthorizedError from Query.queryName to Not authorized to access: Query.queryName (or similar)?

👍 good idea! Feel free to open a PR :)

from graphql-guard.

sshaw avatar sshaw commented on May 27, 2024

PR #32 opened.

These are 2 different behaviours: either fail the whole request with a Ruby exception (and return a > 403 HTTP status, for example) or fail gracefully by returning a response with a GraphQL error.

This is the problem (if I recall): a 403 is not returned. The exception is not handled and an HTTP 500 is returned.

from graphql-guard.

exAspArk avatar exAspArk commented on May 27, 2024

Yeah, right. I usually use something like rescue_from from Rails to catch a specific exception (e.g. NotAuthorizedError) and return 403.

I merged #32. Thank you for your contribution! 🙌

from graphql-guard.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.