Skip to content

Commit

Permalink
Add information about schema masking to README
Browse files Browse the repository at this point in the history
  • Loading branch information
exAspArk committed May 9, 2018
1 parent bfbb99a commit 153c240
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -296,6 +297,22 @@ Schema = GraphQL::Schema.define do
end
</pre>

## Schema masking

It's possible to hide fields from being introspectable and accessible based on the context. For example:

<pre>
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
<b>mask ->(ctx) {</b> ctx[:current_user].beta_tester? <b>}</b>
end
end
</pre>

## Installation

Add this line to your application's Gemfile:
Expand Down

0 comments on commit 153c240

Please sign in to comment.