From 153c240c5ecc65b985540a88fab207951ccabc2c Mon Sep 17 00:00:00 2001 From: exAspArk Date: Wed, 9 May 2018 11:45:17 -0400 Subject: [PATCH] Add information about schema masking to README --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index 88744ef..48d0409 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ This gem provides a field-level authorization for [graphql-ruby](https://github. * [CanCanCan](#cancancan) * [Pundit](#pundit) * [Error handling](#error-handling) +* [Schema masking](#schema-masking) * [Installation](#installation) * [Testing](#testing) * [Development](#development) @@ -296,6 +297,22 @@ Schema = GraphQL::Schema.define do end +## Schema masking + +It's possible to hide fields from being introspectable and accessible based on the context. For example: + +
+PostType = GraphQL::ObjectType.define do
+  name "Post"
+
+  field :id, !types.ID
+  field :title, types.String do
+    # The field "title" is accessible only for beta testers
+    mask ->(ctx) { ctx[:current_user].beta_tester? }
+  end
+end
+
+ ## Installation Add this line to your application's Gemfile: