diff --git a/Rakefile b/Rakefile index 6f5937169..31c2d71ad 100644 --- a/Rakefile +++ b/Rakefile @@ -77,6 +77,11 @@ configure_local_rake_tasks = ->(tasks) do FactoryBot.build(:widget, components: widget_components, inventor: Faker::Base.sample(inventors)) end) + batch.concat(Array.new(10) { FactoryBot.build(:online_store) }) + batch.concat(Array.new(10) { FactoryBot.build(:physical_store) }) + batch.concat(Array.new(5) { FactoryBot.build(:direct_wholesaler) }) + batch.concat(Array.new(5) { FactoryBot.build(:broker_wholesaler) }) + batch.concat(sponsors = Array.new(10) { FactoryBot.build(:sponsor) }) batch.concat(Array.new(10) { FactoryBot.build(:team, sponsors: sponsors.sample(rand(3))) }) batch diff --git a/config/schema/artifacts/data_warehouse.yaml b/config/schema/artifacts/data_warehouse.yaml index 2317dbf8a..6f1c02601 100644 --- a/config/schema/artifacts/data_warehouse.yaml +++ b/config/schema/artifacts/data_warehouse.yaml @@ -14,13 +14,6 @@ tables: shapes ARRAY>>, manufacturer_id STRING ) - companies: - table_schema: |- - CREATE TABLE IF NOT EXISTS companies ( - id STRING, - name STRING, - stock_ticker STRING - ) components: table_schema: |- CREATE TABLE IF NOT EXISTS components ( @@ -62,7 +55,7 @@ tables: id STRING, name STRING, created_at TIMESTAMP, - ceo STRUCT + ceo STRUCT ) mechanical_parts: table_schema: |- @@ -73,12 +66,14 @@ tables: material STRING, manufacturer_id STRING ) - people: + named_inventors: table_schema: |- - CREATE TABLE IF NOT EXISTS people ( + CREATE TABLE IF NOT EXISTS named_inventors ( id STRING, name STRING, - nationality STRING + nationality STRING, + __typename STRING, + stock_ticker STRING ) physical_stores: table_schema: |- @@ -158,8 +153,8 @@ tables: internal_details STRUCT, internal_highlightable_details STRUCT, the_opts STRUCT, - inventor STRUCT, - named_inventor STRUCT, + inventor STRUCT, + named_inventor STRUCT, weight_in_ng_str BIGINT, weight_in_ng BIGINT, tags ARRAY, diff --git a/config/schema/artifacts/datastore_config.yaml b/config/schema/artifacts/datastore_config.yaml index 75f68b263..853b63361 100644 --- a/config/schema/artifacts/datastore_config.yaml +++ b/config/schema/artifacts/datastore_config.yaml @@ -1531,30 +1531,6 @@ indices: index.number_of_replicas: 1 index.number_of_shards: 1 index.max_result_window: 10000 - companies: - aliases: {} - mappings: - dynamic: strict - properties: - id: - type: keyword - name: - type: keyword - stock_ticker: - type: keyword - __sources: - type: keyword - __versions: - type: object - dynamic: 'false' - _size: - enabled: true - settings: - index.mapping.ignore_malformed: false - index.mapping.coerce: false - index.number_of_replicas: 1 - index.number_of_shards: 1 - index.max_result_window: 10000 components: aliases: {} mappings: @@ -1738,7 +1714,7 @@ indices: index.number_of_replicas: 1 index.number_of_shards: 1 index.max_result_window: 10000 - people: + named_inventors: aliases: {} mappings: dynamic: strict @@ -1749,6 +1725,10 @@ indices: type: keyword nationality: type: keyword + stock_ticker: + type: keyword + __typename: + type: keyword __sources: type: keyword __versions: diff --git a/config/schema/artifacts/runtime_metadata.yaml b/config/schema/artifacts/runtime_metadata.yaml index 7dca78d11..46005bf2f 100644 --- a/config/schema/artifacts/runtime_metadata.yaml +++ b/config/schema/artifacts/runtime_metadata.yaml @@ -21,32 +21,6 @@ enum_types_by_name: sort_field: direction: desc field_path: timestamps.created_at - CompanySortOrderInput: - values_by_name: - id_ASC: - sort_field: - direction: asc - field_path: id - id_DESC: - sort_field: - direction: desc - field_path: id - name_ASC: - sort_field: - direction: asc - field_path: name - name_DESC: - sort_field: - direction: desc - field_path: name - stock_ticker_ASC: - sort_field: - direction: asc - field_path: stock_ticker - stock_ticker_DESC: - sort_field: - direction: desc - field_path: stock_ticker ComponentSortOrderInput: values_by_name: created_at_ASC: @@ -897,32 +871,6 @@ enum_types_by_name: sort_field: direction: desc field_path: voltage - PersonSortOrderInput: - values_by_name: - id_ASC: - sort_field: - direction: asc - field_path: id - id_DESC: - sort_field: - direction: desc - field_path: id - name_ASC: - sort_field: - direction: asc - field_path: name - name_DESC: - sort_field: - direction: desc - field_path: name - nationality_ASC: - sort_field: - direction: asc - field_path: nationality - nationality_DESC: - sort_field: - direction: desc - field_path: nationality PhysicalStoreSortOrderInput: values_by_name: established_on_ASC: @@ -1880,17 +1828,6 @@ index_definitions_by_name: timestamps.created_at: source: __self route_with: id - companies: - current_sources: - - __self - fields_by_path: - id: - source: __self - name: - source: __self - stock_ticker: - source: __self - route_with: id components: current_sources: - __self @@ -2008,7 +1945,7 @@ index_definitions_by_name: name: source: __self route_with: id - people: + named_inventors: current_sources: - __self fields_by_path: @@ -2018,6 +1955,8 @@ index_definitions_by_name: source: __self nationality: source: __self + stock_ticker: + source: __self route_with: id physical_stores: current_sources: @@ -3354,9 +3293,11 @@ object_types_by_name: resolver: name: get_record_field_value index_definition_names: - - companies + - named_inventors update_targets: - data_params: + __typename: + cardinality: one name: cardinality: one stock_ticker: @@ -3377,100 +3318,6 @@ object_types_by_name: routing_value_source: id script_id: update_index_data_1fdfaf1c9261c96019decc89b515bd9a type: Company - CompanyAggregatedValues: - graphql_fields_by_name: - id: - resolver: - name: object_with_lookahead - name: - resolver: - name: object_with_lookahead - stock_ticker: - resolver: - name: object_with_lookahead - CompanyAggregation: - elasticgraph_category: indexed_aggregation - graphql_fields_by_name: - aggregated_values: - resolver: - name: object_without_lookahead - count: - resolver: - name: object_without_lookahead - grouped_by: - resolver: - name: object_without_lookahead - source_type: Company - CompanyAggregationConnection: - elasticgraph_category: relay_connection - graphql_fields_by_name: - edges: - resolver: - name: object_without_lookahead - nodes: - resolver: - name: object_without_lookahead - page_info: - resolver: - name: object_without_lookahead - CompanyAggregationEdge: - elasticgraph_category: relay_edge - graphql_fields_by_name: - cursor: - resolver: - name: object_without_lookahead - node: - resolver: - name: object_without_lookahead - CompanyConnection: - elasticgraph_category: relay_connection - graphql_fields_by_name: - edges: - resolver: - name: object_without_lookahead - nodes: - resolver: - name: object_without_lookahead - page_info: - resolver: - name: object_without_lookahead - total_edge_count: - resolver: - name: object_without_lookahead - CompanyEdge: - elasticgraph_category: relay_edge - graphql_fields_by_name: - all_highlights: - resolver: - name: object_without_lookahead - cursor: - resolver: - name: object_without_lookahead - highlights: - resolver: - name: object_without_lookahead - node: - resolver: - name: object_without_lookahead - CompanyGroupedBy: - graphql_fields_by_name: - name: - resolver: - name: object_with_lookahead - stock_ticker: - resolver: - name: object_with_lookahead - CompanyHighlights: - graphql_fields_by_name: - id: - resolver: - name: get_record_field_value - name: - resolver: - name: get_record_field_value - stock_ticker: - resolver: - name: get_record_field_value Component: graphql_fields_by_name: created_at: @@ -5495,6 +5342,8 @@ object_types_by_name: stock_ticker: resolver: name: get_record_field_value + index_definition_names: + - named_inventors NamedInventorAggregatedValues: graphql_fields_by_name: id: @@ -5818,9 +5667,11 @@ object_types_by_name: resolver: name: get_record_field_value index_definition_names: - - people + - named_inventors update_targets: - data_params: + __typename: + cardinality: one name: cardinality: one nationality: @@ -5852,70 +5703,6 @@ object_types_by_name: nationality: resolver: name: object_with_lookahead - PersonAggregation: - elasticgraph_category: indexed_aggregation - graphql_fields_by_name: - aggregated_values: - resolver: - name: object_without_lookahead - count: - resolver: - name: object_without_lookahead - grouped_by: - resolver: - name: object_without_lookahead - source_type: Person - PersonAggregationConnection: - elasticgraph_category: relay_connection - graphql_fields_by_name: - edges: - resolver: - name: object_without_lookahead - nodes: - resolver: - name: object_without_lookahead - page_info: - resolver: - name: object_without_lookahead - PersonAggregationEdge: - elasticgraph_category: relay_edge - graphql_fields_by_name: - cursor: - resolver: - name: object_without_lookahead - node: - resolver: - name: object_without_lookahead - PersonConnection: - elasticgraph_category: relay_connection - graphql_fields_by_name: - edges: - resolver: - name: object_without_lookahead - nodes: - resolver: - name: object_without_lookahead - page_info: - resolver: - name: object_without_lookahead - total_edge_count: - resolver: - name: object_without_lookahead - PersonEdge: - elasticgraph_category: relay_edge - graphql_fields_by_name: - all_highlights: - resolver: - name: object_without_lookahead - cursor: - resolver: - name: object_without_lookahead - highlights: - resolver: - name: object_without_lookahead - node: - resolver: - name: object_without_lookahead PersonGroupedBy: graphql_fields_by_name: name: @@ -6200,12 +5987,6 @@ object_types_by_name: addresses: resolver: name: indexed_type_root_fields - companies: - resolver: - name: indexed_type_root_fields - company_aggregations: - resolver: - name: indexed_type_root_fields component_aggregations: resolver: name: indexed_type_root_fields @@ -6260,12 +6041,6 @@ object_types_by_name: parts: resolver: name: indexed_type_root_fields - people: - resolver: - name: indexed_type_root_fields - person_aggregations: - resolver: - name: indexed_type_root_fields physical_store_aggregations: resolver: name: indexed_type_root_fields diff --git a/config/schema/artifacts/schema.graphql b/config/schema/artifacts/schema.graphql index 11b6f3586..024e43ebe 100644 --- a/config/schema/artifacts/schema.graphql +++ b/config/schema/artifacts/schema.graphql @@ -825,274 +825,6 @@ type Company implements NamedInventor { stock_ticker: String } -""" -Type used to perform aggregation computations on `Company` fields. -""" -type CompanyAggregatedValues { - """ - Computed aggregate values for the `id` field. - """ - id: NonNumericAggregatedValues - - """ - Computed aggregate values for the `name` field. - """ - name: NonNumericAggregatedValues - - """ - Computed aggregate values for the `stock_ticker` field. - """ - stock_ticker: NonNumericAggregatedValues -} - -""" -Return type representing a bucket of `Company` documents for an aggregations query. -""" -type CompanyAggregation { - """ - Provides computed aggregated values over all `Company` documents in an aggregation bucket. - """ - aggregated_values: CompanyAggregatedValues - - """ - The count of `Company` documents in an aggregation bucket. - """ - count: JsonSafeLong! - - """ - Used to specify the `Company` fields to group by. The returned values identify each aggregation bucket. - """ - grouped_by: CompanyGroupedBy -} - -""" -Represents a paginated collection of `CompanyAggregation` results. - -See the [Relay GraphQL Cursor Connections -Specification](https://relay.dev/graphql/connections.htm#sec-Connection-Types) for more info. -""" -type CompanyAggregationConnection { - """ - Wraps a specific `CompanyAggregation` to pair it with its pagination cursor. - """ - edges: [CompanyAggregationEdge!]! - - """ - The list of `CompanyAggregation` results. - """ - nodes: [CompanyAggregation!]! - - """ - Provides pagination-related information. - """ - page_info: PageInfo! -} - -""" -Represents a specific `CompanyAggregation` in the context of a `CompanyAggregationConnection`, -providing access to both the `CompanyAggregation` and query-specific information such as the pagination `Cursor`. - -See the [Relay GraphQL Cursor Connections -Specification](https://relay.dev/graphql/connections.htm#sec-Edge-Types) for more info. -""" -type CompanyAggregationEdge { - """ - The `Cursor` of this `CompanyAggregation`. This can be passed in the next query as - a `before` or `after` argument to continue paginating from this `CompanyAggregation`. - """ - cursor: Cursor - - """ - The `CompanyAggregation` of this edge. - """ - node: CompanyAggregation -} - -""" -Represents a paginated collection of `Company` results. - -See the [Relay GraphQL Cursor Connections -Specification](https://relay.dev/graphql/connections.htm#sec-Connection-Types) for more info. -""" -type CompanyConnection { - """ - Wraps a specific `Company` to pair it with its pagination cursor. - """ - edges: [CompanyEdge!]! - - """ - The list of `Company` results. - """ - nodes: [Company!]! - - """ - Provides pagination-related information. - """ - page_info: PageInfo! - - """ - The total number of edges available in this connection to paginate over. - """ - total_edge_count: JsonSafeLong! -} - -""" -Represents a specific `Company` in the context of a `CompanyConnection`, -providing access to both the `Company` and query-specific information such as the pagination `Cursor`. - -See the [Relay GraphQL Cursor Connections -Specification](https://relay.dev/graphql/connections.htm#sec-Edge-Types) for more info. -""" -type CompanyEdge { - """ - All search highlights for this `Company`, indicating where in the indexed document the query matched. - """ - all_highlights: [SearchHighlight!]! - - """ - The `Cursor` of this `Company`. This can be passed in the next query as - a `before` or `after` argument to continue paginating from this `Company`. - """ - cursor: Cursor - - """ - Specific search highlights for this `Company`, providing matching snippets for the requested fields. - """ - highlights: CompanyHighlights - - """ - The `Company` of this edge. - """ - node: Company -} - -""" -Input type used to specify filters on `Company` fields. - -Will match all documents if passed as an empty object (or as `null`). -""" -input CompanyFilterInput { - """ - Matches records where all of the provided sub-filters evaluate to true. This works just like an AND operator in SQL. - - Note: multiple filters are automatically ANDed together. This is only needed when you have multiple filters that can't - be provided on a single `CompanyFilterInput` input because of collisions - between key names. For example, if you want to AND multiple - OR'd sub-filters (the equivalent of (A OR B) AND (C OR D)), you could do all_of: [{any_of: [...]}, {any_of: [...]}]. - - When `null` or an empty list is passed, matches all documents. - """ - all_of: [CompanyFilterInput!] - - """ - Matches records where any of the provided sub-filters evaluate to true. - This works just like an OR operator in SQL. - - When `null` is passed, matches all documents. - When an empty list is passed, this part of the filter matches no documents. - """ - any_of: [CompanyFilterInput!] - - """ - Used to filter on the `id` field. - - When `null` or an empty object is passed, matches all documents. - """ - id: IDFilterInput - - """ - Used to filter on the `name` field. - - When `null` or an empty object is passed, matches all documents. - """ - name: StringFilterInput - - """ - Matches records where the provided sub-filter evaluates to false. - This works just like a NOT operator in SQL. - - When `null` or an empty object is passed, matches no documents. - """ - not: CompanyFilterInput - - """ - Used to filter on the `stock_ticker` field. - - When `null` or an empty object is passed, matches all documents. - """ - stock_ticker: StringFilterInput -} - -""" -Type used to specify the `Company` fields to group by for aggregations. -""" -type CompanyGroupedBy { - """ - The `name` field value for this group. - """ - name: String - - """ - The `stock_ticker` field value for this group. - """ - stock_ticker: String -} - -""" -Type used to request desired `Company` search highlight fields. -""" -type CompanyHighlights { - """ - Search highlights for the `id`, providing snippets of the matching text. - """ - id: [String!]! - - """ - Search highlights for the `name`, providing snippets of the matching text. - """ - name: [String!]! - - """ - Search highlights for the `stock_ticker`, providing snippets of the matching text. - """ - stock_ticker: [String!]! -} - -""" -Enumerates the ways `Company`s can be sorted. -""" -enum CompanySortOrderInput { - """ - Sorts ascending by the `id` field. - """ - id_ASC - - """ - Sorts descending by the `id` field. - """ - id_DESC - - """ - Sorts ascending by the `name` field. - """ - name_ASC - - """ - Sorts descending by the `name` field. - """ - name_DESC - - """ - Sorts ascending by the `stock_ticker` field. - """ - stock_ticker_ASC - - """ - Sorts descending by the `stock_ticker` field. - """ - stock_ticker_DESC -} - type Component implements NamedEntity { created_at: DateTime! dollar_widget: Widget @@ -8453,127 +8185,6 @@ type PersonAggregatedValues { nationality: NonNumericAggregatedValues } -""" -Return type representing a bucket of `Person` documents for an aggregations query. -""" -type PersonAggregation { - """ - Provides computed aggregated values over all `Person` documents in an aggregation bucket. - """ - aggregated_values: PersonAggregatedValues - - """ - The count of `Person` documents in an aggregation bucket. - """ - count: JsonSafeLong! - - """ - Used to specify the `Person` fields to group by. The returned values identify each aggregation bucket. - """ - grouped_by: PersonGroupedBy -} - -""" -Represents a paginated collection of `PersonAggregation` results. - -See the [Relay GraphQL Cursor Connections -Specification](https://relay.dev/graphql/connections.htm#sec-Connection-Types) for more info. -""" -type PersonAggregationConnection { - """ - Wraps a specific `PersonAggregation` to pair it with its pagination cursor. - """ - edges: [PersonAggregationEdge!]! - - """ - The list of `PersonAggregation` results. - """ - nodes: [PersonAggregation!]! - - """ - Provides pagination-related information. - """ - page_info: PageInfo! -} - -""" -Represents a specific `PersonAggregation` in the context of a `PersonAggregationConnection`, -providing access to both the `PersonAggregation` and query-specific information such as the pagination `Cursor`. - -See the [Relay GraphQL Cursor Connections -Specification](https://relay.dev/graphql/connections.htm#sec-Edge-Types) for more info. -""" -type PersonAggregationEdge { - """ - The `Cursor` of this `PersonAggregation`. This can be passed in the next query as - a `before` or `after` argument to continue paginating from this `PersonAggregation`. - """ - cursor: Cursor - - """ - The `PersonAggregation` of this edge. - """ - node: PersonAggregation -} - -""" -Represents a paginated collection of `Person` results. - -See the [Relay GraphQL Cursor Connections -Specification](https://relay.dev/graphql/connections.htm#sec-Connection-Types) for more info. -""" -type PersonConnection { - """ - Wraps a specific `Person` to pair it with its pagination cursor. - """ - edges: [PersonEdge!]! - - """ - The list of `Person` results. - """ - nodes: [Person!]! - - """ - Provides pagination-related information. - """ - page_info: PageInfo! - - """ - The total number of edges available in this connection to paginate over. - """ - total_edge_count: JsonSafeLong! -} - -""" -Represents a specific `Person` in the context of a `PersonConnection`, -providing access to both the `Person` and query-specific information such as the pagination `Cursor`. - -See the [Relay GraphQL Cursor Connections -Specification](https://relay.dev/graphql/connections.htm#sec-Edge-Types) for more info. -""" -type PersonEdge { - """ - All search highlights for this `Person`, indicating where in the indexed document the query matched. - """ - all_highlights: [SearchHighlight!]! - - """ - The `Cursor` of this `Person`. This can be passed in the next query as - a `before` or `after` argument to continue paginating from this `Person`. - """ - cursor: Cursor - - """ - Specific search highlights for this `Person`, providing matching snippets for the requested fields. - """ - highlights: PersonHighlights - - """ - The `Person` of this edge. - """ - node: Person -} - """ Input type used to specify filters on `Person` fields. @@ -8666,41 +8277,6 @@ type PersonHighlights { nationality: [String!]! } -""" -Enumerates the ways `Person`s can be sorted. -""" -enum PersonSortOrderInput { - """ - Sorts ascending by the `id` field. - """ - id_ASC - - """ - Sorts descending by the `id` field. - """ - id_DESC - - """ - Sorts ascending by the `name` field. - """ - name_ASC - - """ - Sorts descending by the `name` field. - """ - name_DESC - - """ - Sorts ascending by the `nationality` field. - """ - nationality_ASC - - """ - Sorts descending by the `nationality` field. - """ - nationality_DESC -} - type PhysicalStore implements DistributionChannel & Retail & Store { active: Boolean established_on: Date @@ -9700,109 +9276,6 @@ type Query { order_by: [AddressSortOrderInput!] ): AddressConnection - """ - Fetches `Company`s based on the provided arguments. - """ - companies( - """ - Used to forward-paginate through the `companies`. When provided, the next page after the - provided cursor will be returned. - - See the [Relay GraphQL Cursor Connections - Specification](https://relay.dev/graphql/connections.htm#sec-Arguments) for more info. - """ - after: Cursor - - """ - Used to backward-paginate through the `companies`. When provided, the previous page before the - provided cursor will be returned. - - See the [Relay GraphQL Cursor Connections - Specification](https://relay.dev/graphql/connections.htm#sec-Arguments) for more info. - """ - before: Cursor - - """ - Used to filter the returned `companies` based on the provided criteria. - """ - filter: CompanyFilterInput - - """ - Used in conjunction with the `after` argument to forward-paginate through the `companies`. - When provided, limits the number of returned results to the first `n` after the provided - `after` cursor (or from the start of the `companies`, if no `after` cursor is provided). - - See the [Relay GraphQL Cursor Connections - Specification](https://relay.dev/graphql/connections.htm#sec-Arguments) for more info. - """ - first: Int - - """ - Used in conjunction with the `before` argument to backward-paginate through the `companies`. - When provided, limits the number of returned results to the last `n` before the provided - `before` cursor (or from the end of the `companies`, if no `before` cursor is provided). - - See the [Relay GraphQL Cursor Connections - Specification](https://relay.dev/graphql/connections.htm#sec-Arguments) for more info. - """ - last: Int - - """ - Used to specify how the returned `companies` should be sorted. - """ - order_by: [CompanySortOrderInput!] - ): CompanyConnection - - """ - Aggregations over the `companies` data: - - > Fetches `Company`s based on the provided arguments. - """ - company_aggregations( - """ - Used to forward-paginate through the `company_aggregations`. When provided, the next page after the - provided cursor will be returned. - - See the [Relay GraphQL Cursor Connections - Specification](https://relay.dev/graphql/connections.htm#sec-Arguments) for more info. - """ - after: Cursor - - """ - Used to backward-paginate through the `company_aggregations`. When provided, the previous page before the - provided cursor will be returned. - - See the [Relay GraphQL Cursor Connections - Specification](https://relay.dev/graphql/connections.htm#sec-Arguments) for more info. - """ - before: Cursor - - """ - Used to filter the `Company` documents that get aggregated over based on the provided criteria. - """ - filter: CompanyFilterInput - - """ - Used in conjunction with the `after` argument to forward-paginate through the `company_aggregations`. - When provided, limits the number of returned results to the first `n` after the provided - `after` cursor (or from the start of the `company_aggregations`, if no `after` cursor is provided). - - See the [Relay GraphQL Cursor Connections - Specification](https://relay.dev/graphql/connections.htm#sec-Arguments) for more info. - """ - first: Int - - """ - Used in conjunction with the `before` argument to backward-paginate through the `company_aggregations`. - When provided, limits the number of returned results to the last `n` before the provided - `before` cursor (or from the end of the `company_aggregations`, if no `before` cursor is provided). - - See the [Relay GraphQL Cursor Connections - Specification](https://relay.dev/graphql/connections.htm#sec-Arguments) for more info. - """ - last: Int - ): CompanyAggregationConnection - """ Aggregations over the `components` data: @@ -10730,109 +10203,6 @@ type Query { order_by: [PartSortOrderInput!] ): PartConnection - """ - Fetches `Person`s based on the provided arguments. - """ - people( - """ - Used to forward-paginate through the `people`. When provided, the next page after the - provided cursor will be returned. - - See the [Relay GraphQL Cursor Connections - Specification](https://relay.dev/graphql/connections.htm#sec-Arguments) for more info. - """ - after: Cursor - - """ - Used to backward-paginate through the `people`. When provided, the previous page before the - provided cursor will be returned. - - See the [Relay GraphQL Cursor Connections - Specification](https://relay.dev/graphql/connections.htm#sec-Arguments) for more info. - """ - before: Cursor - - """ - Used to filter the returned `people` based on the provided criteria. - """ - filter: PersonFilterInput - - """ - Used in conjunction with the `after` argument to forward-paginate through the `people`. - When provided, limits the number of returned results to the first `n` after the provided - `after` cursor (or from the start of the `people`, if no `after` cursor is provided). - - See the [Relay GraphQL Cursor Connections - Specification](https://relay.dev/graphql/connections.htm#sec-Arguments) for more info. - """ - first: Int - - """ - Used in conjunction with the `before` argument to backward-paginate through the `people`. - When provided, limits the number of returned results to the last `n` before the provided - `before` cursor (or from the end of the `people`, if no `before` cursor is provided). - - See the [Relay GraphQL Cursor Connections - Specification](https://relay.dev/graphql/connections.htm#sec-Arguments) for more info. - """ - last: Int - - """ - Used to specify how the returned `people` should be sorted. - """ - order_by: [PersonSortOrderInput!] - ): PersonConnection - - """ - Aggregations over the `people` data: - - > Fetches `Person`s based on the provided arguments. - """ - person_aggregations( - """ - Used to forward-paginate through the `person_aggregations`. When provided, the next page after the - provided cursor will be returned. - - See the [Relay GraphQL Cursor Connections - Specification](https://relay.dev/graphql/connections.htm#sec-Arguments) for more info. - """ - after: Cursor - - """ - Used to backward-paginate through the `person_aggregations`. When provided, the previous page before the - provided cursor will be returned. - - See the [Relay GraphQL Cursor Connections - Specification](https://relay.dev/graphql/connections.htm#sec-Arguments) for more info. - """ - before: Cursor - - """ - Used to filter the `Person` documents that get aggregated over based on the provided criteria. - """ - filter: PersonFilterInput - - """ - Used in conjunction with the `after` argument to forward-paginate through the `person_aggregations`. - When provided, limits the number of returned results to the first `n` after the provided - `after` cursor (or from the start of the `person_aggregations`, if no `after` cursor is provided). - - See the [Relay GraphQL Cursor Connections - Specification](https://relay.dev/graphql/connections.htm#sec-Arguments) for more info. - """ - first: Int - - """ - Used in conjunction with the `before` argument to backward-paginate through the `person_aggregations`. - When provided, limits the number of returned results to the last `n` before the provided - `before` cursor (or from the end of the `person_aggregations`, if no `before` cursor is provided). - - See the [Relay GraphQL Cursor Connections - Specification](https://relay.dev/graphql/connections.htm#sec-Arguments) for more info. - """ - last: Int - ): PersonAggregationConnection - """ Aggregations over the `physical_stores` data: diff --git a/config/schema/artifacts_with_apollo/data_warehouse.yaml b/config/schema/artifacts_with_apollo/data_warehouse.yaml index 2317dbf8a..6f1c02601 100644 --- a/config/schema/artifacts_with_apollo/data_warehouse.yaml +++ b/config/schema/artifacts_with_apollo/data_warehouse.yaml @@ -14,13 +14,6 @@ tables: shapes ARRAY>>, manufacturer_id STRING ) - companies: - table_schema: |- - CREATE TABLE IF NOT EXISTS companies ( - id STRING, - name STRING, - stock_ticker STRING - ) components: table_schema: |- CREATE TABLE IF NOT EXISTS components ( @@ -62,7 +55,7 @@ tables: id STRING, name STRING, created_at TIMESTAMP, - ceo STRUCT + ceo STRUCT ) mechanical_parts: table_schema: |- @@ -73,12 +66,14 @@ tables: material STRING, manufacturer_id STRING ) - people: + named_inventors: table_schema: |- - CREATE TABLE IF NOT EXISTS people ( + CREATE TABLE IF NOT EXISTS named_inventors ( id STRING, name STRING, - nationality STRING + nationality STRING, + __typename STRING, + stock_ticker STRING ) physical_stores: table_schema: |- @@ -158,8 +153,8 @@ tables: internal_details STRUCT, internal_highlightable_details STRUCT, the_opts STRUCT, - inventor STRUCT, - named_inventor STRUCT, + inventor STRUCT, + named_inventor STRUCT, weight_in_ng_str BIGINT, weight_in_ng BIGINT, tags ARRAY, diff --git a/config/schema/artifacts_with_apollo/datastore_config.yaml b/config/schema/artifacts_with_apollo/datastore_config.yaml index 75f68b263..853b63361 100644 --- a/config/schema/artifacts_with_apollo/datastore_config.yaml +++ b/config/schema/artifacts_with_apollo/datastore_config.yaml @@ -1531,30 +1531,6 @@ indices: index.number_of_replicas: 1 index.number_of_shards: 1 index.max_result_window: 10000 - companies: - aliases: {} - mappings: - dynamic: strict - properties: - id: - type: keyword - name: - type: keyword - stock_ticker: - type: keyword - __sources: - type: keyword - __versions: - type: object - dynamic: 'false' - _size: - enabled: true - settings: - index.mapping.ignore_malformed: false - index.mapping.coerce: false - index.number_of_replicas: 1 - index.number_of_shards: 1 - index.max_result_window: 10000 components: aliases: {} mappings: @@ -1738,7 +1714,7 @@ indices: index.number_of_replicas: 1 index.number_of_shards: 1 index.max_result_window: 10000 - people: + named_inventors: aliases: {} mappings: dynamic: strict @@ -1749,6 +1725,10 @@ indices: type: keyword nationality: type: keyword + stock_ticker: + type: keyword + __typename: + type: keyword __sources: type: keyword __versions: diff --git a/config/schema/artifacts_with_apollo/runtime_metadata.yaml b/config/schema/artifacts_with_apollo/runtime_metadata.yaml index e23db3bf6..dfb191604 100644 --- a/config/schema/artifacts_with_apollo/runtime_metadata.yaml +++ b/config/schema/artifacts_with_apollo/runtime_metadata.yaml @@ -21,32 +21,6 @@ enum_types_by_name: sort_field: direction: desc field_path: timestamps.created_at - CompanySortOrderInput: - values_by_name: - id_ASC: - sort_field: - direction: asc - field_path: id - id_DESC: - sort_field: - direction: desc - field_path: id - name_ASC: - sort_field: - direction: asc - field_path: name - name_DESC: - sort_field: - direction: desc - field_path: name - stock_ticker_ASC: - sort_field: - direction: asc - field_path: stock_ticker - stock_ticker_DESC: - sort_field: - direction: desc - field_path: stock_ticker ComponentSortOrderInput: values_by_name: created_at_ASC: @@ -897,32 +871,6 @@ enum_types_by_name: sort_field: direction: desc field_path: voltage - PersonSortOrderInput: - values_by_name: - id_ASC: - sort_field: - direction: asc - field_path: id - id_DESC: - sort_field: - direction: desc - field_path: id - name_ASC: - sort_field: - direction: asc - field_path: name - name_DESC: - sort_field: - direction: desc - field_path: name - nationality_ASC: - sort_field: - direction: asc - field_path: nationality - nationality_DESC: - sort_field: - direction: desc - field_path: nationality PhysicalStoreSortOrderInput: values_by_name: established_on_ASC: @@ -1909,17 +1857,6 @@ index_definitions_by_name: timestamps.created_at: source: __self route_with: id - companies: - current_sources: - - __self - fields_by_path: - id: - source: __self - name: - source: __self - stock_ticker: - source: __self - route_with: id components: current_sources: - __self @@ -2037,7 +1974,7 @@ index_definitions_by_name: name: source: __self route_with: id - people: + named_inventors: current_sources: - __self fields_by_path: @@ -2047,6 +1984,8 @@ index_definitions_by_name: source: __self nationality: source: __self + stock_ticker: + source: __self route_with: id physical_stores: current_sources: @@ -3383,9 +3322,11 @@ object_types_by_name: resolver: name: get_record_field_value index_definition_names: - - companies + - named_inventors update_targets: - data_params: + __typename: + cardinality: one name: cardinality: one stock_ticker: @@ -3406,100 +3347,6 @@ object_types_by_name: routing_value_source: id script_id: update_index_data_1fdfaf1c9261c96019decc89b515bd9a type: Company - CompanyAggregatedValues: - graphql_fields_by_name: - id: - resolver: - name: object_with_lookahead - name: - resolver: - name: object_with_lookahead - stock_ticker: - resolver: - name: object_with_lookahead - CompanyAggregation: - elasticgraph_category: indexed_aggregation - graphql_fields_by_name: - aggregated_values: - resolver: - name: object_without_lookahead - count: - resolver: - name: object_without_lookahead - grouped_by: - resolver: - name: object_without_lookahead - source_type: Company - CompanyAggregationConnection: - elasticgraph_category: relay_connection - graphql_fields_by_name: - edges: - resolver: - name: object_without_lookahead - nodes: - resolver: - name: object_without_lookahead - page_info: - resolver: - name: object_without_lookahead - CompanyAggregationEdge: - elasticgraph_category: relay_edge - graphql_fields_by_name: - cursor: - resolver: - name: object_without_lookahead - node: - resolver: - name: object_without_lookahead - CompanyConnection: - elasticgraph_category: relay_connection - graphql_fields_by_name: - edges: - resolver: - name: object_without_lookahead - nodes: - resolver: - name: object_without_lookahead - page_info: - resolver: - name: object_without_lookahead - total_edge_count: - resolver: - name: object_without_lookahead - CompanyEdge: - elasticgraph_category: relay_edge - graphql_fields_by_name: - all_highlights: - resolver: - name: object_without_lookahead - cursor: - resolver: - name: object_without_lookahead - highlights: - resolver: - name: object_without_lookahead - node: - resolver: - name: object_without_lookahead - CompanyGroupedBy: - graphql_fields_by_name: - name: - resolver: - name: object_with_lookahead - stock_ticker: - resolver: - name: object_with_lookahead - CompanyHighlights: - graphql_fields_by_name: - id: - resolver: - name: get_record_field_value - name: - resolver: - name: get_record_field_value - stock_ticker: - resolver: - name: get_record_field_value Component: graphql_fields_by_name: created_at: @@ -5618,6 +5465,8 @@ object_types_by_name: stock_ticker: resolver: name: get_record_field_value + index_definition_names: + - named_inventors NamedInventorAggregatedValues: graphql_fields_by_name: id: @@ -5941,9 +5790,11 @@ object_types_by_name: resolver: name: get_record_field_value index_definition_names: - - people + - named_inventors update_targets: - data_params: + __typename: + cardinality: one name: cardinality: one nationality: @@ -5975,70 +5826,6 @@ object_types_by_name: nationality: resolver: name: object_with_lookahead - PersonAggregation: - elasticgraph_category: indexed_aggregation - graphql_fields_by_name: - aggregated_values: - resolver: - name: object_without_lookahead - count: - resolver: - name: object_without_lookahead - grouped_by: - resolver: - name: object_without_lookahead - source_type: Person - PersonAggregationConnection: - elasticgraph_category: relay_connection - graphql_fields_by_name: - edges: - resolver: - name: object_without_lookahead - nodes: - resolver: - name: object_without_lookahead - page_info: - resolver: - name: object_without_lookahead - PersonAggregationEdge: - elasticgraph_category: relay_edge - graphql_fields_by_name: - cursor: - resolver: - name: object_without_lookahead - node: - resolver: - name: object_without_lookahead - PersonConnection: - elasticgraph_category: relay_connection - graphql_fields_by_name: - edges: - resolver: - name: object_without_lookahead - nodes: - resolver: - name: object_without_lookahead - page_info: - resolver: - name: object_without_lookahead - total_edge_count: - resolver: - name: object_without_lookahead - PersonEdge: - elasticgraph_category: relay_edge - graphql_fields_by_name: - all_highlights: - resolver: - name: object_without_lookahead - cursor: - resolver: - name: object_without_lookahead - highlights: - resolver: - name: object_without_lookahead - node: - resolver: - name: object_without_lookahead PersonGroupedBy: graphql_fields_by_name: name: @@ -6329,12 +6116,6 @@ object_types_by_name: addresses: resolver: name: indexed_type_root_fields - companies: - resolver: - name: indexed_type_root_fields - company_aggregations: - resolver: - name: indexed_type_root_fields component_aggregations: resolver: name: indexed_type_root_fields @@ -6389,12 +6170,6 @@ object_types_by_name: parts: resolver: name: indexed_type_root_fields - people: - resolver: - name: indexed_type_root_fields - person_aggregations: - resolver: - name: indexed_type_root_fields physical_store_aggregations: resolver: name: indexed_type_root_fields diff --git a/config/schema/artifacts_with_apollo/schema.graphql b/config/schema/artifacts_with_apollo/schema.graphql index fc033758c..1418fd751 100644 --- a/config/schema/artifacts_with_apollo/schema.graphql +++ b/config/schema/artifacts_with_apollo/schema.graphql @@ -858,274 +858,6 @@ type Company implements NamedInventor @key(fields: "id") { stock_ticker: String } -""" -Type used to perform aggregation computations on `Company` fields. -""" -type CompanyAggregatedValues { - """ - Computed aggregate values for the `id` field. - """ - id: NonNumericAggregatedValues - - """ - Computed aggregate values for the `name` field. - """ - name: NonNumericAggregatedValues - - """ - Computed aggregate values for the `stock_ticker` field. - """ - stock_ticker: NonNumericAggregatedValues -} - -""" -Return type representing a bucket of `Company` documents for an aggregations query. -""" -type CompanyAggregation { - """ - Provides computed aggregated values over all `Company` documents in an aggregation bucket. - """ - aggregated_values: CompanyAggregatedValues - - """ - The count of `Company` documents in an aggregation bucket. - """ - count: JsonSafeLong! - - """ - Used to specify the `Company` fields to group by. The returned values identify each aggregation bucket. - """ - grouped_by: CompanyGroupedBy -} - -""" -Represents a paginated collection of `CompanyAggregation` results. - -See the [Relay GraphQL Cursor Connections -Specification](https://relay.dev/graphql/connections.htm#sec-Connection-Types) for more info. -""" -type CompanyAggregationConnection { - """ - Wraps a specific `CompanyAggregation` to pair it with its pagination cursor. - """ - edges: [CompanyAggregationEdge!]! - - """ - The list of `CompanyAggregation` results. - """ - nodes: [CompanyAggregation!]! - - """ - Provides pagination-related information. - """ - page_info: PageInfo! -} - -""" -Represents a specific `CompanyAggregation` in the context of a `CompanyAggregationConnection`, -providing access to both the `CompanyAggregation` and query-specific information such as the pagination `Cursor`. - -See the [Relay GraphQL Cursor Connections -Specification](https://relay.dev/graphql/connections.htm#sec-Edge-Types) for more info. -""" -type CompanyAggregationEdge { - """ - The `Cursor` of this `CompanyAggregation`. This can be passed in the next query as - a `before` or `after` argument to continue paginating from this `CompanyAggregation`. - """ - cursor: Cursor - - """ - The `CompanyAggregation` of this edge. - """ - node: CompanyAggregation -} - -""" -Represents a paginated collection of `Company` results. - -See the [Relay GraphQL Cursor Connections -Specification](https://relay.dev/graphql/connections.htm#sec-Connection-Types) for more info. -""" -type CompanyConnection { - """ - Wraps a specific `Company` to pair it with its pagination cursor. - """ - edges: [CompanyEdge!]! - - """ - The list of `Company` results. - """ - nodes: [Company!]! - - """ - Provides pagination-related information. - """ - page_info: PageInfo! - - """ - The total number of edges available in this connection to paginate over. - """ - total_edge_count: JsonSafeLong! -} - -""" -Represents a specific `Company` in the context of a `CompanyConnection`, -providing access to both the `Company` and query-specific information such as the pagination `Cursor`. - -See the [Relay GraphQL Cursor Connections -Specification](https://relay.dev/graphql/connections.htm#sec-Edge-Types) for more info. -""" -type CompanyEdge { - """ - All search highlights for this `Company`, indicating where in the indexed document the query matched. - """ - all_highlights: [SearchHighlight!]! - - """ - The `Cursor` of this `Company`. This can be passed in the next query as - a `before` or `after` argument to continue paginating from this `Company`. - """ - cursor: Cursor - - """ - Specific search highlights for this `Company`, providing matching snippets for the requested fields. - """ - highlights: CompanyHighlights - - """ - The `Company` of this edge. - """ - node: Company -} - -""" -Input type used to specify filters on `Company` fields. - -Will match all documents if passed as an empty object (or as `null`). -""" -input CompanyFilterInput { - """ - Matches records where all of the provided sub-filters evaluate to true. This works just like an AND operator in SQL. - - Note: multiple filters are automatically ANDed together. This is only needed when you have multiple filters that can't - be provided on a single `CompanyFilterInput` input because of collisions - between key names. For example, if you want to AND multiple - OR'd sub-filters (the equivalent of (A OR B) AND (C OR D)), you could do all_of: [{any_of: [...]}, {any_of: [...]}]. - - When `null` or an empty list is passed, matches all documents. - """ - all_of: [CompanyFilterInput!] - - """ - Matches records where any of the provided sub-filters evaluate to true. - This works just like an OR operator in SQL. - - When `null` is passed, matches all documents. - When an empty list is passed, this part of the filter matches no documents. - """ - any_of: [CompanyFilterInput!] - - """ - Used to filter on the `id` field. - - When `null` or an empty object is passed, matches all documents. - """ - id: IDFilterInput - - """ - Used to filter on the `name` field. - - When `null` or an empty object is passed, matches all documents. - """ - name: StringFilterInput - - """ - Matches records where the provided sub-filter evaluates to false. - This works just like a NOT operator in SQL. - - When `null` or an empty object is passed, matches no documents. - """ - not: CompanyFilterInput - - """ - Used to filter on the `stock_ticker` field. - - When `null` or an empty object is passed, matches all documents. - """ - stock_ticker: StringFilterInput -} - -""" -Type used to specify the `Company` fields to group by for aggregations. -""" -type CompanyGroupedBy { - """ - The `name` field value for this group. - """ - name: String - - """ - The `stock_ticker` field value for this group. - """ - stock_ticker: String -} - -""" -Type used to request desired `Company` search highlight fields. -""" -type CompanyHighlights { - """ - Search highlights for the `id`, providing snippets of the matching text. - """ - id: [String!]! - - """ - Search highlights for the `name`, providing snippets of the matching text. - """ - name: [String!]! - - """ - Search highlights for the `stock_ticker`, providing snippets of the matching text. - """ - stock_ticker: [String!]! -} - -""" -Enumerates the ways `Company`s can be sorted. -""" -enum CompanySortOrderInput { - """ - Sorts ascending by the `id` field. - """ - id_ASC - - """ - Sorts descending by the `id` field. - """ - id_DESC - - """ - Sorts ascending by the `name` field. - """ - name_ASC - - """ - Sorts descending by the `name` field. - """ - name_DESC - - """ - Sorts ascending by the `stock_ticker` field. - """ - stock_ticker_ASC - - """ - Sorts descending by the `stock_ticker` field. - """ - stock_ticker_DESC -} - type Component implements NamedEntity @key(fields: "id") { created_at: DateTime! dollar_widget: Widget @@ -8735,127 +8467,6 @@ type PersonAggregatedValues { nationality: NonNumericAggregatedValues } -""" -Return type representing a bucket of `Person` documents for an aggregations query. -""" -type PersonAggregation { - """ - Provides computed aggregated values over all `Person` documents in an aggregation bucket. - """ - aggregated_values: PersonAggregatedValues - - """ - The count of `Person` documents in an aggregation bucket. - """ - count: JsonSafeLong! - - """ - Used to specify the `Person` fields to group by. The returned values identify each aggregation bucket. - """ - grouped_by: PersonGroupedBy -} - -""" -Represents a paginated collection of `PersonAggregation` results. - -See the [Relay GraphQL Cursor Connections -Specification](https://relay.dev/graphql/connections.htm#sec-Connection-Types) for more info. -""" -type PersonAggregationConnection { - """ - Wraps a specific `PersonAggregation` to pair it with its pagination cursor. - """ - edges: [PersonAggregationEdge!]! - - """ - The list of `PersonAggregation` results. - """ - nodes: [PersonAggregation!]! - - """ - Provides pagination-related information. - """ - page_info: PageInfo! -} - -""" -Represents a specific `PersonAggregation` in the context of a `PersonAggregationConnection`, -providing access to both the `PersonAggregation` and query-specific information such as the pagination `Cursor`. - -See the [Relay GraphQL Cursor Connections -Specification](https://relay.dev/graphql/connections.htm#sec-Edge-Types) for more info. -""" -type PersonAggregationEdge { - """ - The `Cursor` of this `PersonAggregation`. This can be passed in the next query as - a `before` or `after` argument to continue paginating from this `PersonAggregation`. - """ - cursor: Cursor - - """ - The `PersonAggregation` of this edge. - """ - node: PersonAggregation -} - -""" -Represents a paginated collection of `Person` results. - -See the [Relay GraphQL Cursor Connections -Specification](https://relay.dev/graphql/connections.htm#sec-Connection-Types) for more info. -""" -type PersonConnection { - """ - Wraps a specific `Person` to pair it with its pagination cursor. - """ - edges: [PersonEdge!]! - - """ - The list of `Person` results. - """ - nodes: [Person!]! - - """ - Provides pagination-related information. - """ - page_info: PageInfo! - - """ - The total number of edges available in this connection to paginate over. - """ - total_edge_count: JsonSafeLong! -} - -""" -Represents a specific `Person` in the context of a `PersonConnection`, -providing access to both the `Person` and query-specific information such as the pagination `Cursor`. - -See the [Relay GraphQL Cursor Connections -Specification](https://relay.dev/graphql/connections.htm#sec-Edge-Types) for more info. -""" -type PersonEdge { - """ - All search highlights for this `Person`, indicating where in the indexed document the query matched. - """ - all_highlights: [SearchHighlight!]! - - """ - The `Cursor` of this `Person`. This can be passed in the next query as - a `before` or `after` argument to continue paginating from this `Person`. - """ - cursor: Cursor - - """ - Specific search highlights for this `Person`, providing matching snippets for the requested fields. - """ - highlights: PersonHighlights - - """ - The `Person` of this edge. - """ - node: Person -} - """ Input type used to specify filters on `Person` fields. @@ -8948,41 +8559,6 @@ type PersonHighlights { nationality: [String!]! } -""" -Enumerates the ways `Person`s can be sorted. -""" -enum PersonSortOrderInput { - """ - Sorts ascending by the `id` field. - """ - id_ASC - - """ - Sorts descending by the `id` field. - """ - id_DESC - - """ - Sorts ascending by the `name` field. - """ - name_ASC - - """ - Sorts descending by the `name` field. - """ - name_DESC - - """ - Sorts ascending by the `nationality` field. - """ - nationality_ASC - - """ - Sorts descending by the `nationality` field. - """ - nationality_DESC -} - type PhysicalStore implements DistributionChannel & Retail & Store @key(fields: "id") { active: Boolean established_on: Date @@ -10023,109 +9599,6 @@ type Query { order_by: [AddressSortOrderInput!] ): AddressConnection - """ - Fetches `Company`s based on the provided arguments. - """ - companies( - """ - Used to forward-paginate through the `companies`. When provided, the next page after the - provided cursor will be returned. - - See the [Relay GraphQL Cursor Connections - Specification](https://relay.dev/graphql/connections.htm#sec-Arguments) for more info. - """ - after: Cursor - - """ - Used to backward-paginate through the `companies`. When provided, the previous page before the - provided cursor will be returned. - - See the [Relay GraphQL Cursor Connections - Specification](https://relay.dev/graphql/connections.htm#sec-Arguments) for more info. - """ - before: Cursor - - """ - Used to filter the returned `companies` based on the provided criteria. - """ - filter: CompanyFilterInput - - """ - Used in conjunction with the `after` argument to forward-paginate through the `companies`. - When provided, limits the number of returned results to the first `n` after the provided - `after` cursor (or from the start of the `companies`, if no `after` cursor is provided). - - See the [Relay GraphQL Cursor Connections - Specification](https://relay.dev/graphql/connections.htm#sec-Arguments) for more info. - """ - first: Int - - """ - Used in conjunction with the `before` argument to backward-paginate through the `companies`. - When provided, limits the number of returned results to the last `n` before the provided - `before` cursor (or from the end of the `companies`, if no `before` cursor is provided). - - See the [Relay GraphQL Cursor Connections - Specification](https://relay.dev/graphql/connections.htm#sec-Arguments) for more info. - """ - last: Int - - """ - Used to specify how the returned `companies` should be sorted. - """ - order_by: [CompanySortOrderInput!] - ): CompanyConnection - - """ - Aggregations over the `companies` data: - - > Fetches `Company`s based on the provided arguments. - """ - company_aggregations( - """ - Used to forward-paginate through the `company_aggregations`. When provided, the next page after the - provided cursor will be returned. - - See the [Relay GraphQL Cursor Connections - Specification](https://relay.dev/graphql/connections.htm#sec-Arguments) for more info. - """ - after: Cursor - - """ - Used to backward-paginate through the `company_aggregations`. When provided, the previous page before the - provided cursor will be returned. - - See the [Relay GraphQL Cursor Connections - Specification](https://relay.dev/graphql/connections.htm#sec-Arguments) for more info. - """ - before: Cursor - - """ - Used to filter the `Company` documents that get aggregated over based on the provided criteria. - """ - filter: CompanyFilterInput - - """ - Used in conjunction with the `after` argument to forward-paginate through the `company_aggregations`. - When provided, limits the number of returned results to the first `n` after the provided - `after` cursor (or from the start of the `company_aggregations`, if no `after` cursor is provided). - - See the [Relay GraphQL Cursor Connections - Specification](https://relay.dev/graphql/connections.htm#sec-Arguments) for more info. - """ - first: Int - - """ - Used in conjunction with the `before` argument to backward-paginate through the `company_aggregations`. - When provided, limits the number of returned results to the last `n` before the provided - `before` cursor (or from the end of the `company_aggregations`, if no `before` cursor is provided). - - See the [Relay GraphQL Cursor Connections - Specification](https://relay.dev/graphql/connections.htm#sec-Arguments) for more info. - """ - last: Int - ): CompanyAggregationConnection - """ Aggregations over the `components` data: @@ -11053,109 +10526,6 @@ type Query { order_by: [PartSortOrderInput!] ): PartConnection - """ - Fetches `Person`s based on the provided arguments. - """ - people( - """ - Used to forward-paginate through the `people`. When provided, the next page after the - provided cursor will be returned. - - See the [Relay GraphQL Cursor Connections - Specification](https://relay.dev/graphql/connections.htm#sec-Arguments) for more info. - """ - after: Cursor - - """ - Used to backward-paginate through the `people`. When provided, the previous page before the - provided cursor will be returned. - - See the [Relay GraphQL Cursor Connections - Specification](https://relay.dev/graphql/connections.htm#sec-Arguments) for more info. - """ - before: Cursor - - """ - Used to filter the returned `people` based on the provided criteria. - """ - filter: PersonFilterInput - - """ - Used in conjunction with the `after` argument to forward-paginate through the `people`. - When provided, limits the number of returned results to the first `n` after the provided - `after` cursor (or from the start of the `people`, if no `after` cursor is provided). - - See the [Relay GraphQL Cursor Connections - Specification](https://relay.dev/graphql/connections.htm#sec-Arguments) for more info. - """ - first: Int - - """ - Used in conjunction with the `before` argument to backward-paginate through the `people`. - When provided, limits the number of returned results to the last `n` before the provided - `before` cursor (or from the end of the `people`, if no `before` cursor is provided). - - See the [Relay GraphQL Cursor Connections - Specification](https://relay.dev/graphql/connections.htm#sec-Arguments) for more info. - """ - last: Int - - """ - Used to specify how the returned `people` should be sorted. - """ - order_by: [PersonSortOrderInput!] - ): PersonConnection - - """ - Aggregations over the `people` data: - - > Fetches `Person`s based on the provided arguments. - """ - person_aggregations( - """ - Used to forward-paginate through the `person_aggregations`. When provided, the next page after the - provided cursor will be returned. - - See the [Relay GraphQL Cursor Connections - Specification](https://relay.dev/graphql/connections.htm#sec-Arguments) for more info. - """ - after: Cursor - - """ - Used to backward-paginate through the `person_aggregations`. When provided, the previous page before the - provided cursor will be returned. - - See the [Relay GraphQL Cursor Connections - Specification](https://relay.dev/graphql/connections.htm#sec-Arguments) for more info. - """ - before: Cursor - - """ - Used to filter the `Person` documents that get aggregated over based on the provided criteria. - """ - filter: PersonFilterInput - - """ - Used in conjunction with the `after` argument to forward-paginate through the `person_aggregations`. - When provided, limits the number of returned results to the first `n` after the provided - `after` cursor (or from the start of the `person_aggregations`, if no `after` cursor is provided). - - See the [Relay GraphQL Cursor Connections - Specification](https://relay.dev/graphql/connections.htm#sec-Arguments) for more info. - """ - first: Int - - """ - Used in conjunction with the `before` argument to backward-paginate through the `person_aggregations`. - When provided, limits the number of returned results to the last `n` before the provided - `before` cursor (or from the end of the `person_aggregations`, if no `before` cursor is provided). - - See the [Relay GraphQL Cursor Connections - Specification](https://relay.dev/graphql/connections.htm#sec-Arguments) for more info. - """ - last: Int - ): PersonAggregationConnection - """ Aggregations over the `physical_stores` data: diff --git a/config/schema/widgets.rb b/config/schema/widgets.rb index e50f4490e..e2ff59b6a 100644 --- a/config/schema/widgets.rb +++ b/config/schema/widgets.rb @@ -33,35 +33,37 @@ t.field "name", "String" end + # Person serves two roles: it is indexed as a top-level queryable type (via NamedInventor's + # index inheritance) and embedded as Manufacturer.ceo. This dual role is intentional — it + # exercises that the indexer correctly injects __typename when preparing Person for the + # shared named_inventors index, but omits it when embedding Person in manufacturers. schema.object_type "Person" do |t| t.implements "NamedInventor" - t.root_query_fields plural: "people" t.field "id", "ID!" t.field "name", "String" t.field "nationality", "String" - t.index "people" end schema.object_type "Company" do |t| t.implements "NamedInventor" - t.root_query_fields plural: "companies" t.field "id", "ID!" t.field "name", "String" t.field "stock_ticker", "String" - t.index "companies" end schema.union_type "Inventor" do |t| t.subtypes "Person", "Company" end - # Interface type used both as an embedded field and as a root document type. + # Indexed interface type. Person and Company inherit the `named_inventors` index via + # index inheritance rather than declaring it themselves. schema.interface_type "NamedInventor" do |t| t.field "id", "ID!" t.field "name", "String" + t.index "named_inventors" end - # Indexed interfae type. + # Indexed interface type. schema.interface_type "NamedEntity" do |t| t.root_query_fields plural: "named_entities" t.field "id", "ID!" diff --git a/config/settings/development.yaml b/config/settings/development.yaml index f14211b9a..2f2129e69 100644 --- a/config/settings/development.yaml +++ b/config/settings/development.yaml @@ -18,8 +18,7 @@ datastore: setting_overrides_by_timestamp: {} components: *main_index_settings electrical_parts: *main_index_settings - companies: *main_index_settings - people: *main_index_settings + named_inventors: *main_index_settings manufacturers: *main_index_settings mechanical_parts: *main_index_settings teams: *main_index_settings diff --git a/config/settings/development_with_apollo.yaml b/config/settings/development_with_apollo.yaml index eacd259c0..9cb085d24 100644 --- a/config/settings/development_with_apollo.yaml +++ b/config/settings/development_with_apollo.yaml @@ -18,8 +18,7 @@ datastore: setting_overrides_by_timestamp: {} components: *main_index_settings electrical_parts: *main_index_settings - companies: *main_index_settings - people: *main_index_settings + named_inventors: *main_index_settings manufacturers: *main_index_settings mechanical_parts: *main_index_settings teams: *main_index_settings diff --git a/config/settings/test.yaml.template b/config/settings/test.yaml.template index 9cf7fe795..94ae2e2ca 100644 --- a/config/settings/test.yaml.template +++ b/config/settings/test.yaml.template @@ -36,8 +36,7 @@ datastore: setting_overrides_by_timestamp: {} components: *main_index_settings electrical_parts: *main_index_settings - companies: *main_index_settings - people: *main_index_settings + named_inventors: *main_index_settings manufacturers: *main_index_settings mechanical_parts: *main_index_settings teams: *main_index_settings diff --git a/elasticgraph-graphql/spec/acceptance/hidden_types_spec.rb b/elasticgraph-graphql/spec/acceptance/hidden_types_spec.rb index 519bccab6..e25c611df 100644 --- a/elasticgraph-graphql/spec/acceptance/hidden_types_spec.rb +++ b/elasticgraph-graphql/spec/acceptance/hidden_types_spec.rb @@ -78,8 +78,6 @@ module ElasticGraph all_types_related_to("WidgetCurrency") + all_types_related_to("Team") + all_types_related_to("Sponsor") + - all_types_related_to("Person") + - all_types_related_to("Company") + all_types_related_to("Inventor") + all_types_related_to("NamedInventor") + all_types_related_to("DistributionChannel") + @@ -106,6 +104,7 @@ module ElasticGraph type_filter_and_non_indexed_aggregation_types_for("Affiliations", include_fields_list_filter: true) + type_filter_and_non_indexed_aggregation_types_for("CurrencyDetails") + type_filter_and_non_indexed_aggregation_types_for("Money", include_list_filter: true, include_fields_list_filter: true) - ["MoneyListElementFilterInput"] + + type_filter_and_non_indexed_aggregation_types_for("Person") + type_filter_and_non_indexed_aggregation_types_for("Position", include_highlights: false) + type_filter_and_non_indexed_aggregation_types_for("Player", include_list_filter: true, include_fields_list_filter: true) - ["PlayerListElementFilterInput"] + type_filter_and_non_indexed_aggregation_types_for("PlayerSeason", include_list_filter: true, include_fields_list_filter: true) - ["PlayerSeasonListElementFilterInput"] + @@ -121,7 +120,7 @@ module ElasticGraph %w[ FloatAggregatedValues IntAggregatedValues JsonSafeLongAggregatedValues LongStringAggregatedValues NonNumericAggregatedValues DateAggregatedValues DateTimeAggregatedValues LocalTimeAggregatedValues - OnlineStore DirectWholesaler BrokerWholesaler + Company OnlineStore DirectWholesaler BrokerWholesaler Cursor PageInfo Query TextFilterInput GeoLocation DateTimeGroupingOffsetInput DateTimeUnitInput DateTimeTimeOfDayFilterInput DateGroupedBy DateGroupingOffsetInput DateGroupingTruncationUnitInput DateUnitInput diff --git a/elasticgraph-graphql/spec/acceptance/search_spec.rb b/elasticgraph-graphql/spec/acceptance/search_spec.rb index 9f7474c36..05ccc7813 100644 --- a/elasticgraph-graphql/spec/acceptance/search_spec.rb +++ b/elasticgraph-graphql/spec/acceptance/search_spec.rb @@ -698,28 +698,163 @@ module ElasticGraph test_widget_search_highlighting(widget1, widget2, widget3) end - it "resolves all_highlights against the concrete type for documents in a shared-index hierarchy" do - # OnlineStore.name is a field specific to OnlineStore — absent from DistributionChannel. - # Without __typename-aware type resolution in all_highlights, the highlight response from - # the datastore would be resolved against the wrong type (e.g. DistributionChannel), causing - # the name highlight to be silently dropped. + it "correctly scopes results to the queried interface level across a multi-level type hierarchy", :expect_search_routing do + established_on_asc = :"#{case_correctly("established_on")}_ASC" + id_desc = :"#{case_correctly("id")}_DESC" + + # The DistributionChannel hierarchy has two branches: + # DistributionChannel (index: distribution_channels) + # ├── Wholesale (interface, inherits distribution_channels) + # │ ├── DirectWholesaler (concrete, distribution_channels index) + # │ └── BrokerWholesaler (concrete, distribution_channels index) + # └── Retail (interface, inherits distribution_channels) + # └── Store (interface, inherits distribution_channels) + # ├── OnlineStore (concrete, distribution_channels index) + # └── PhysicalStore (concrete, physical_stores index) + # + # The critical behavior under test: querying at a sub-interface level (e.g. retailers, stores) + # must filter OUT non-subtypes in the shared index (e.g. Wholesale subtypes when querying stores). index_records( - online_store = build(:online_store, name: "Example Marketplace"), - build(:online_store, name: "Other Store"), - build(:direct_wholesaler) + physical_store1 = build(:physical_store, established_on: "2019-03-10", active: true), + physical_store2 = build(:physical_store, established_on: "2022-08-05", active: true), + online_store1 = build(:online_store, established_on: "2020-01-15", active: true, name: "Example Marketplace"), + online_store2 = build(:online_store, established_on: "2021-06-20", active: true), + build(:direct_wholesaler, active: true), + wholesaler2 = build(:broker_wholesaler, active: false) ) + store_fragments = [ + "...on PhysicalStore { id __typename established_on }", + "...on OnlineStore { id __typename established_on }" + ] + wholesale_fragment = "...on DirectWholesaler { id __typename active }" + all_channel_fragments = store_fragments + [wholesale_fragment, "...on BrokerWholesaler { id __typename active }"] + + expected_store_typenames = %w[PhysicalStore PhysicalStore OnlineStore OnlineStore] + + # Querying at the top-level DistributionChannel interface returns all concrete types, + # including DirectWholesaler and BrokerWholesaler. + channels = list_distribution_channels_with(*all_channel_fragments) + expect(channels.map { |c| c["__typename"] }).to contain_exactly( + *expected_store_typenames, "DirectWholesaler", "BrokerWholesaler" + ) + + # Querying at the Retail interface excludes wholesalers, even though they live in + # the same distribution_channels index. + retailers = list_retailers_with(*store_fragments) + expect(retailers.map { |r| r["__typename"] }).to contain_exactly(*expected_store_typenames) + + # Querying at the Store interface likewise excludes wholesalers. + stores = list_stores_with(*store_fragments) + expect(stores.map { |s| s["__typename"] }).to contain_exactly(*expected_store_typenames) + + # Using `nodes` (instead of `edges { node }`) also works. This exercises the `nodes` + # code path where the field type is list-wrapped (e.g. `[Store!]!`). + stores_via_nodes = list_stores_via_nodes_with(*store_fragments) + expect(stores_via_nodes.map { |s| s["__typename"] }).to contain_exactly(*expected_store_typenames) + + # Filters apply within the correct scope at each level. + # At distribution_channels: active=false matches only wholesaler2. + inactive = list_distribution_channels_with(*all_channel_fragments, filter: {active: {equal_to_any_of: [false]}}) + expect(inactive.map { |c| c["__typename"] }).to contain_exactly("BrokerWholesaler") + expect(inactive.map { |c| c["id"] }).to contain_exactly(wholesaler2.fetch(:id)) + + # At retailers: established_on filter applies, and wholesalers are still excluded. + retailers_after_2020 = list_retailers_with(*store_fragments, filter: {established_on: {gte: "2020-01-01"}}) + expect(retailers_after_2020.map { |r| r["id"] }).to contain_exactly( + online_store1.fetch(:id), online_store2.fetch(:id), + physical_store2.fetch(:id) + ) + + # Sort by established_on at the stores level spans both indices correctly. + stores_sorted = list_stores_with(*store_fragments, order_by: [established_on_asc]) + expect(stores_sorted.map { |s| s["id"] }).to eq([ + physical_store1.fetch(:id), + online_store1.fetch(:id), + online_store2.fetch(:id), + physical_store2.fetch(:id) + ]) + + # Pagination at the distribution_channels level covers all types. + channels_page, page_info = list_distribution_channels_and_page_info_with( + *all_channel_fragments, + first: 4, + order_by: [id_desc] + ) + expect(channels_page.size).to eq(4) + expect(page_info).to include(case_correctly("has_next_page") => true) + + # Filter by ID spans indices and respects the __typename scope at each query level. + stores_by_id = list_stores_with( + *store_fragments, + filter: {id: {equal_to_any_of: [physical_store1.fetch(:id), online_store1.fetch(:id)]}} + ) + expect(stores_by_id.map { |s| [s["id"], s["__typename"]] }).to contain_exactly( + [physical_store1.fetch(:id), "PhysicalStore"], + [online_store1.fetch(:id), "OnlineStore"] + ) + + # Aggregations respect the same __typename scoping as document queries. + store_agg_count = call_graphql_query("query { #{case_correctly("store_aggregations")} { nodes { #{case_correctly("count")} } } }") + .dig("data", case_correctly("store_aggregations"), "nodes", 0, case_correctly("count")) + expect(store_agg_count).to eq(expected_store_typenames.size) + + # all_highlights resolves against the concrete type (OnlineStore), not the abstract root + # (DistributionChannel). OnlineStore.name is absent from DistributionChannel — without + # __typename-aware type resolution the highlight would be silently dropped. highlights_by_id = query_all_highlights("retailers", filter: { "name" => {"contains" => {"any_substring_of" => ["Marketplace"]}} }) - expect(highlights_by_id).to eq({ - online_store.fetch(:id) => [ + online_store1.fetch(:id) => [ {"path" => ["name"], "snippets" => ["Example Marketplace"]} ] }) end + it "supports querying a type that is both indexed (via interface inheritance) and embedded as a field on another type" do + # Person is dual-role: it inherits the `named_inventors` index from NamedInventor, and + # is also embedded as Manufacturer.ceo. Both roles must work correctly in the same run: + # the indexer injects __typename when preparing Person for named_inventors, but omits it + # when preparing Person for the manufacturers index (where ceo has no __typename mapping). + person = build(:person, name: "Alice", nationality: "Canadian") + company = build(:company, name: "Acme", stock_ticker: "ACME") + + index_records( + person, + company, + build(:manufacturer, name: "m1", ceo: person.as_embedded) + ) + + # Querying named_inventors returns both concrete subtypes, distinguished by __typename. + inventors = query_abstract_type_with( + case_correctly("named_inventors"), + "...on Person { id __typename name nationality }", + "...on Company { id __typename name #{case_correctly("stock_ticker")} }" + ).dig("data", case_correctly("named_inventors"), "edges").map { |e| e.fetch("node") } + + expect(inventors).to contain_exactly( + {"id" => person.fetch(:id), "__typename" => "Person", "name" => "Alice", "nationality" => "Canadian"}, + {"id" => company.fetch(:id), "__typename" => "Company", "name" => "Acme", case_correctly("stock_ticker") => "ACME"} + ) + + # Person embedded as Manufacturer.ceo is also queryable, with no __typename in the result. + manufacturers = call_graphql_query(<<~QUERY).dig("data", "manufacturers", "nodes") + query { + manufacturers { + nodes { + name + ceo { name nationality } + } + } + } + QUERY + + expect(manufacturers).to contain_exactly( + {"name" => "m1", "ceo" => {"name" => "Alice", "nationality" => "Canadian"}} + ) + end + it "supports fetching interface fields" do index_into( graphql, @@ -1512,6 +1647,62 @@ def list_widgets_via_widgets_or_addresses(**query_args) QUERY end + def list_distribution_channels_with(*fragments, **query_args) + field = case_correctly("distribution_channels") + query_abstract_type_with(field, *fragments, **query_args).dig("data", field, "edges").map { |e| e.fetch("node") } + end + + def list_distribution_channels_and_page_info_with(*fragments, **query_args) + field = case_correctly("distribution_channels") + response = query_abstract_type_with(field, *fragments, **query_args).dig("data", field) + [response.fetch("edges").map { |e| e.fetch("node") }, response.fetch(case_correctly("page_info"))] + end + + def list_retailers_with(*fragments, **query_args) + query_abstract_type_with("retailers", *fragments, **query_args).dig("data", "retailers", "edges").map { |e| e.fetch("node") } + end + + def list_stores_with(*fragments, **query_args) + query_abstract_type_with("stores", *fragments, **query_args).dig("data", "stores", "edges").map { |e| e.fetch("node") } + end + + def list_stores_via_nodes_with(*fragments, **query_args) + query_abstract_type_via_nodes_with("stores", *fragments, **query_args).dig("data", "stores", "nodes") + end + + def query_abstract_type_with(field, *fragments, allow_errors: false, **query_args) + fragment_string = fragments.join("\n") + call_graphql_query(<<~QUERY, allow_errors: allow_errors) + query { + #{field}#{graphql_args(query_args)} { + #{case_correctly("page_info")} { + #{case_correctly("end_cursor")} + #{case_correctly("has_next_page")} + #{case_correctly("has_previous_page")} + } + edges { + node { + #{fragment_string} + } + } + } + } + QUERY + end + + def query_abstract_type_via_nodes_with(field, *fragments, **query_args) + fragment_string = fragments.join("\n") + call_graphql_query(<<~QUERY) + query { + #{field}#{graphql_args(query_args)} { + nodes { + #{fragment_string} + } + } + } + QUERY + end + def list_widgets_by_nodes_with(fieldname, **query_args) query_widgets_by_nodes_with(fieldname, **query_args).dig("data", "widgets", "nodes") end diff --git a/spec_support/lib/elastic_graph/spec_support/factories/widgets.rb b/spec_support/lib/elastic_graph/spec_support/factories/widgets.rb index 0c0032892..df0b6f379 100644 --- a/spec_support/lib/elastic_graph/spec_support/factories/widgets.rb +++ b/spec_support/lib/elastic_graph/spec_support/factories/widgets.rb @@ -47,12 +47,14 @@ factory :person, parent: :indexed_type do __typename { "Person" } + id { Faker::Alphanumeric.alpha(number: 20) } name { Faker::Name.name } nationality { Faker::Nation.nationality } end factory :company, parent: :indexed_type do __typename { "Company" } + id { Faker::Alphanumeric.alpha(number: 20) } name { Faker::Company.name } stock_ticker { name[0..3].upcase } end