GithubHelp home page GithubHelp logo

Comments (11)

Tyflomate avatar Tyflomate commented on May 28, 2024 2

It is a classic RoR implementation of graphql. It is hard to give you a code example since it is a private repository :/ I tried overriding it in BaseMutation/BaseObject/ApplicationController(root of my graphql controller) classes. I put a pry inside each of my implementations but none was reached. In each of these classes i just did this:

def authorization_namespace
     ::UserApplication
end

If we have for example a policy like this: UserApplication::TotoPolicy.
I also put a pry inside the library to see the output of this method but for a mutation Mutations::UserApplication::TestMutation, it would always return Mutations::UserApplication.

from action_policy-graphql.

Tyflomate avatar Tyflomate commented on May 28, 2024 1

It may be good to notice that in BaseMutation and BaseObject I have included include ActionPolicy::GraphQL::Behaviour

from action_policy-graphql.

Tyflomate avatar Tyflomate commented on May 28, 2024 1

Sorry didn't have the time to work again on this issue, but we might try again in another context we we'll see the result

from action_policy-graphql.

palkan avatar palkan commented on May 28, 2024

Could you please provide a code example? Where do you include Action Policy behaviour and where do you override (and how) #authorization_namespace? I will try to reproduce it

from action_policy-graphql.

palkan avatar palkan commented on May 28, 2024

Thanks for the details! (And sorry for late response)

I will do my best to work on this till the end of the year 🙂

from action_policy-graphql.

palkan avatar palkan commented on May 28, 2024

@Tyflomate I tried to reproduce the problem here but with no luck: 58e89be

Maybe, you can try to tweak our test examples to demonstrate the failing case?

from action_policy-graphql.

palkan avatar palkan commented on May 28, 2024

Hey @Tyflomate! Was this issue resolved? And if not, could you please help with the reproduction (see the prev comment)?

from action_policy-graphql.

gael-ian avatar gael-ian commented on May 28, 2024

Hello @palkan

I encountered the same problem yesterday, maybe in another form.

Our environment is pretty much the same as @Tyflomate. To deduplicate behaviour declaration between our GraphQL types and mutations, I used an ActiveSupport::Concern to include in both base mutation and base object.

So far, it looks like:

module Authorizations
  extend ActiveSupport::Concern

  included do
    include ActionPolicy::GraphQL::Behaviour
    prepend LookupMethods
  end

  module LookupMethods
    def authorization_namespace = ::Api
    def default_authorization_policy_class = ::ApiPolicy
  end
end

We need to use prepend or lookup methods declared in action_policy/behaviours/namespaced.rb take precedence over our version of authorization_namespace.

On the other side, default_authorization_policy_class works however we define it: prepended, included or extended. I would have expected authorization_namespace to work the same.

from action_policy-graphql.

palkan avatar palkan commented on May 28, 2024

Hey @gael-ian!

Thanks for the snippet.

I see what's going on here: we define the #authorization_namespace method right on the class:

def base.authorization_namespace

That's why include doesn't work.

Agree, this is confusing, let's fix it.

from action_policy-graphql.

palkan avatar palkan commented on May 28, 2024

Nope, the code I linked above only affects authorized? callbacks—is this your case @gael-ian ? Otherwise, overriding #authorization_namespace works fine, see f0129eb

from action_policy-graphql.

palkan avatar palkan commented on May 28, 2024

Okay, thanks; closing for now; will re-open if the problem occurs again.

from action_policy-graphql.

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.