exAspArk / graphql-guard

Simple authorization gem for GraphQL :lock:
MIT License
472 stars 36 forks source link

Can't test guard proc on Mutation root #19

Closed Yoshiji closed 6 years ago

Yoshiji commented 6 years ago

Related to the documentation on the testing of the guard proc: https://github.com/exAspArk/graphql-guard#testing

The documentation suggests that I should be able to do QueryType.field_with_guard('posts'), but when I try to do it with my own Mutations::Root object (which is a GraphQL::ObjectType), I get a no method error for field_with_guard:

Mutations::Root.field_with_guard('some_existing_mutation_endpoint')
NoMethodError: undefined method `field_with_guard' for Mutation:GraphQL::ObjectType

It seems to be the same for all other object types I defined in my GraphQL schema using graphql-ruby v1.8.4 and graphql-guard 1.0.0 & 1.2.0 (tested with both).

exAspArk commented 6 years ago

Hey @Yoshiji,

Did you add require "graphql/guard/testing" line to your tests?

Yoshiji commented 6 years ago

Hey @exAspArk,

Thank you for your answer. It fixed my problem. I am sorry I did not read the documentation properly 🙈

Thank you also for developing this very useful gem!