Skip to content

[PD-20757] - add after_assign_attributes and authorized? methods for grapqhl resources#65

Open
santiagoarce wants to merge 4 commits intoOneHQ:masterfrom
santiagoarce:PD-20757
Open

[PD-20757] - add after_assign_attributes and authorized? methods for grapqhl resources#65
santiagoarce wants to merge 4 commits intoOneHQ:masterfrom
santiagoarce:PD-20757

Conversation

@santiagoarce
Copy link
Copy Markdown

Description

Please describe your pull request and any relevant information.

Checklist

  • I have added appropriate tests if this PR fixes a bug or adds a feature.
  • All status checks (tests, linting, etc...) are passing.

@kylejginavan
Copy link
Copy Markdown
Member

Task linked: PD-20757 Add Sharing section

@santiagoarce santiagoarce changed the title [PD-20757] - add after_assign_attributes methods for grapqhl resources [PD-20757] - add after_assign_attributes and authorized? methods for grapqhl resources Sep 10, 2025
def build_mutation(action:, require_primary_key: false, nil_klass: false, &block)
gql_name = "#{graphql_name}#{action.to_s.titleize}"
scoped_model_name = model_name
scoped_self = self
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need this?

Comment thread lib/hq/graphql/ext/object_extensions.rb Outdated
def authorized?(object, context)
super && ::HQ::GraphQL.authorized?(authorized_action, object, context)
def authorized?(object, context, args = nil)
super(object, context) && ::HQ::GraphQL.authorized?(authorized_action, object, context, args)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we passing object and context to super? did we changed this method? is it better to use **args? so we dont have to default it to nil?

Comment thread lib/hq/graphql.rb Outdated

def self.authorized?(action, object, context)
!config.authorize || config.authorize.call(action, object, context)
def self.authorized?(action, object, context, args)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe the method signature is **args just so we dont make it mandatory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants