Module: ElasticGraph::Apollo::SchemaDefinition::GraphQLSDLEnumeratorExtension
- Defined in:
- lib/elastic_graph/apollo/schema_definition/graphql_sdl_enumerator_extension.rb
Overview
Module designed to be extended onto an ‘ElasticGraph::SchemaDefinition::GraphQLSDLEnumerator` instance to customize the schema artifacts to support Apollo.
Instance Method Summary collapse
Instance Method Details
#root_query_type ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/elastic_graph/apollo/schema_definition/graphql_sdl_enumerator_extension.rb', line 15 def root_query_type super.tap do |type_or_nil| # @type var type: ElasticGraph::SchemaDefinition::SchemaElements::ObjectType type = _ = type_or_nil if schema_def_state.object_types_by_name.values.any?(&:indexed?) type.field "_entities", "[_Entity]!" do |f| f.documentation " A field required by the [Apollo Federation subgraph\n spec](https://www.apollographql.com/docs/federation/subgraph-spec/#query_entities):\n\n > The graph router uses this root-level `Query` field to directly fetch fields of entities defined by a subgraph.\n >\n > This field must take a `representations` argument of type `[_Any!]!` (a non-nullable list of non-nullable\n > [`_Any` scalars](https://www.apollographql.com/docs/federation/subgraph-spec/#scalar-_any)). Its return type must be `[_Entity]!` (a non-nullable list of _nullable_\n > objects that belong to the [`_Entity` union](https://www.apollographql.com/docs/federation/subgraph-spec/#union-_entity)).\n >\n > Each entry in the `representations` list must be validated with the following rules:\n >\n > - A representation must include a `__typename` string field.\n > - A representation must contain all fields included in the fieldset of a `@key` directive applied to the corresponding entity definition.\n >\n > For details, see [Resolving entity fields with `Query._entities`](https://www.apollographql.com/docs/federation/subgraph-spec/#resolving-entity-fields-with-query_entities).\n\n Not intended for use by clients other than Apollo.\n EOS\n\n f.argument \"representations\", \"[_Any!]!\" do |a|\n a.documentation <<~EOS\n A list of entity data blobs from other apollo subgraphs. For more information (and\n to see an example of what form this argument takes), see the [Apollo Federation subgraph\n spec](https://www.apollographql.com/docs/federation/subgraph-spec/#resolve-requests-for-entities).\n EOS\n end\n end\n end\n\n type.field \"_service\", \"_Service!\" do |f|\n f.documentation <<~EOS\n A field required by the [Apollo Federation subgraph\n spec](https://www.apollographql.com/docs/federation/subgraph-spec/#query_service):\n\n > This field of the root `Query` type must return a non-nullable [`_Service` type](https://www.apollographql.com/docs/federation/subgraph-spec/#type-_service).\n\n > For details, see [Enhanced introspection with `Query._service`](https://www.apollographql.com/docs/federation/subgraph-spec/#enhanced-introspection-with-query_service).\n\n Not intended for use by clients other than Apollo.\n EOS\n end\n end\nend\n" |