Module: ElasticGraph::Apollo::SchemaDefinition::ApolloDirectives::Provides

Included in:
FieldExtension
Defined in:
elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/apollo_directives.rb

Overview

Supports Apollo’s @provides directive.

Instance Method Summary collapse

Instance Method Details

#apollo_provides(fields:) ⇒ void

This method returns an undefined value.

Adds the @provides directive to the schema element.

Examples:

Add @provides to a field

ElasticGraph.define_schema do |schema|
  schema.object_type "Product" do |t|
    t.field "name", "String"
  end

  schema.object_type "StoreLocation" do |t|
    t.field "products", "[Product!]!" do |f|
      f.mapping type: "nested"
      f.apollo_provides fields: "name"
    end
  end
end

Parameters:

  • fields (String)

    A GraphQL selection set (provided as a string) of object fields and subfields that the subgraph can resolve only at this query path.



196
197
198
# File 'elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/apollo_directives.rb', line 196

def apollo_provides(fields:)
  directive "provides", fields: fields
end