Module: ElasticGraph::Apollo::SchemaDefinition::APIExtension
- Defined in:
- elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/api_extension.rb
Overview
Module designed to be extended onto an SchemaDefinition::API instance to customize the schema artifacts based on the Apollo Federation subgraph spec.
To use this module, pass it in schema_definition_extension_modules
when defining your Local::RakeTasks.
Instance Method Summary collapse
-
#tag_built_in_types_with(name, except: []) ⇒ void
Applies an apollo tag to built-in types so that they are included in the Apollo contract schema.
-
#target_apollo_federation_version(version) ⇒ void
Picks which version of Apollo federation to target.
Instance Method Details
#tag_built_in_types_with(name, except: []) ⇒ void
This method returns an undefined value.
Applies an apollo tag to built-in types so that they are included in the Apollo contract schema.
82 83 84 85 86 87 88 |
# File 'elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/api_extension.rb', line 82 def tag_built_in_types_with(name, except: []) except_set = except.to_set on_built_in_types do |type| apollo_type = (_ = type) # : ApolloDirectives::Tag apollo_type.apollo_tag(name: name) unless except_set.include?(type.name) end end |
#target_apollo_federation_version(version) ⇒ void
This method returns an undefined value.
Picks which version of Apollo federation to target. By default, the latest supported version is targeted, but you can call this to pick an earlier version, which may be necessary if your organization is on an older version of Apollo federation.
101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'elasticgraph-apollo/lib/elastic_graph/apollo/schema_definition/api_extension.rb', line 101 def target_apollo_federation_version(version) # Allow the version to have the `v` prefix, but don't require it. version = version.delete_prefix("v") state.apollo_directive_definitions = DIRECTIVE_DEFINITIONS_BY_FEDERATION_VERSION.fetch(version) do supported_version_descriptions = DIRECTIVE_DEFINITIONS_BY_FEDERATION_VERSION.keys.map do |version_number| "v#{version_number}" end.join(", ") raise Errors::SchemaError, "elasticgraph-apollo v#{ElasticGraph::VERSION} does not support Apollo federation v#{version}. " \ "Pick one of the supported versions (#{supported_version_descriptions}) instead." end end |