Module: ElasticGraph::Apollo::SchemaDefinition::ApolloDirectives::RequiresScopes

Included in:
EnumTypeExtension, FieldExtension, InterfaceTypeExtension, ObjectTypeExtension, ScalarTypeExtension
Defined in:
elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/apollo_directives.rb

Overview

Supports Apollo’s @requiresScopes directive.

Instance Method Summary collapse

Instance Method Details

#apollo_requires_scopes(scopes:) ⇒ void

This method returns an undefined value.

Adds the @requiresScopes directive to the schema element.

Examples:

Add @requiresScopes to a field

ElasticGraph.define_schema do |schema|
  schema.object_type "Product" do |t|
    t.field "shippingEstimate", "String" do |f|
      f.apollo_requires_scopes scopes: "shipping"
    end
  end
end

Parameters:

  • scopes (Array<String>)

    List of JWT scopes that must be granted to the user in order to access the underlying element data.



241
242
243
# File 'elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/apollo_directives.rb', line 241

def apollo_requires_scopes(scopes:)
  directive "requiresScopes", scopes: scopes
end