-
I'm trying to add some field authorization, copy/pasting the example in the docs: class Types::BaseField < GraphQL::Schema::Field
# Pass `field ..., require_admin: true` to reject non-admin users from a given field
def initialize(*args, **kwargs, require_admin: false, &block)
@require_admin = require_admin
super(*args, **kwargs, &block)
end
def authorized?(obj, args, ctx)
# if `require_admin:` was given, then require the current user to be an admin
super && (@require_admin ? ctx[:viewer]&.admin? : true)
end
end I've added However, I'm getting a syntax error when I run any query:
I don't believe there are any typos; if i comment out |
Beta Was this translation helpful? Give feedback.
Answered by
nimmolo
Feb 15, 2022
Replies: 1 comment 2 replies
-
Oh my goodness. Of course there is a syntax error... |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
nimmolo
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Oh my goodness. Of course there is a syntax error...
Added params must come immediately after
*args
and before**kwargs