Module: ElasticGraph::GraphQL::MonkeyPatches::SchemaFieldVisibilityDecorator
- Included in:
- GraphQL::Schema::Field
- Defined in:
- lib/elastic_graph/graphql/monkey_patches/schema_field.rb
Overview
This module is designed to monkey patch ‘GraphQL::Schema::Field`, but to do so in a conservative, safe way:
-
It defines no new methods.
-
It delegates to the original implementation with ‘super` unless we are sure that a type should be hidden.
-
It only changes the behavior for ElasticGraph schemas (as indicated by ‘:elastic_graph_schema` in the `context`).
Instance Method Summary collapse
Instance Method Details
#visible?(context) ⇒ Boolean
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/elastic_graph/graphql/monkey_patches/schema_field.rb', line 21 def visible?(context) # `DynamicFields` and `EntryPoints` are built-in introspection types that `field_named` below doesn't support: # https://github.com/rmosolgo/graphql-ruby/blob/0df187995c971b399ed7cc1fbdcbd958af6c4ade/lib/graphql/introspection/entry_points.rb # https://github.com/rmosolgo/graphql-ruby/blob/0df187995c971b399ed7cc1fbdcbd958af6c4ade/lib/graphql/introspection/dynamic_fields.rb # # ...so if the owner is one of those we just return `super` here. return super if %w[DynamicFields EntryPoints].include?(owner.graphql_name) if context[:elastic_graph_schema]&.field_named(owner.graphql_name, graphql_name)&.hidden_from_queries? return false end super end |