Closed danwetherald closed 4 years ago
class ShopType < Types::BaseObject
field :title, String, null: true
field :user, Types::Models::UserType, null: true do
guard ->(obj, args, ctx) { ctx[:current_user] && ctx[:current_shop] }
end
end
Just for anyone else who is looking to add guarded fields on BaseObjects.
Thank you @dan003400. Right, the existing documentation was written by using the previous graphql
gem schema-definition DSL.
For those who would like to contribute and update the readme to use class-based schema definitions, here is an example from the gem specs:
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
How would you include a guard on this field for the ShopType, we would like to limit the field user to only signed in users, but allow the other fields on a shop to be public without the need for authentication.