Module: GraphQL

Defined in:
lib/elastic_graph/graphql/monkey_patches/schema_field.rb

Overview

As per graphql-ruby.org/authorization/visibility.html, the public API provided by the GraphQL gem to control visibility of object types is to define a ‘visible?` instance method on a custom subclass of `GraphQL::Schema::Field`. However, because we load our schema from an SDL definition rather than defining classes for each schema type, we don’t have a way to register a custom subclass to be used for fields.

So, here we solve this a slightly different way: we prepend a module onto the ‘GraphQL::Schema::Field class. This allows our module to act like a decorator and intercept calls to `visible?` so that it can hide types as needed.

Defined Under Namespace

Classes: Schema