Closed ducnguyenhuy-agilityio closed 6 years ago
Hey @ducnguyenhuy,
Probably the example in the README is a bit confusing. You should create and pass obj, args, ctx
variables explicitly. For example:
rentals = Types::QueryType.field_with_guard('rentals', GraphqlPolicy)
object = Something.find(1)
arguments = {}
context = {current_user: User.find(1)} # or {}, for example
result = rentals.guard(object, arguments, context)
expect(result).to eq(true)
So, consider it as a unit-test where you explicitly pass input variables and get the output.
@exAspArk It worked. Thanks. It will be better if you replace the above example with the example in README. Let me close this.
I have created a spec file as below:
When I try to run
rspec
, I got an error as followings:Please let me know what I'm wrong?