Closed webdobe closed 5 years ago
Hey, try this:
def people(**arguments)
Resolvers::PeopleSearch.call(filters: arguments, object: object, context: context)
end
Then you class you can do:
scope { Person.visible_by(context[:current_user] }
I'm working on update that will remove the need for def people
. The issue I have to support both old style of GraphQL gem and the new one.
Hi @RStankov, Really appreciate you providing quick feedback. When I do what you mention I get the error wrong number of arguments (given 1, expected 3)
. If I do:
def people(**arguments)
byebug
Resolvers::PeopleSearch.call(object, arguments, context)
end
byebug prints my all three of those fine.
require 'search_object'
require 'search_object/plugin/graphql'
class Resolvers::PeopleSearch
# include SearchObject for GraphQL
include SearchObject.module(:graphql)
type types[Types::PersonType]
byebug
scope { Person.visible_by(object) }
byebug does not print a thing for object or context both being nil.
Hm, what do you mean by:
byebug does not print a thing for object or context both being nil.
in people
object
and context
are nil?
Hi Sorry, I should have replied. I was able to get passed this. I was calling visible_by instead of visible_to which was the name of my method. I am still unsure why those arguments (object & context) are nil when they get to the Class but they appear that way in byebug. But then they work... So I guess I am still just a rails newbie and not sure how to debug. Thank you for your help!
No worries, glad to help :)
Hello thank you for the taking care of this project.
I am running into issues trying to get context and arguments to modify the scope.
If I use this for my query passing my class as a function arguments and context do not get passed in to the class.
If I do that and say:
Only arguments get passed into the people definition and unable to grab the context.
I understand this may have nothing to do with the SearchObject class but curious if I am even going about this correctly.
as trying to modify the scope via the initialize then makes my sort and filter option get bypassed
In the end I am trying to limit the scope based on user permissions. Any feedback would be appreciated.
There is this stack overflow question that fits the build but no one has really made any valuable feedback to it: https://stackoverflow.com/questions/51957480/how-to-pass-current-user-in-graphql-resolver