Class: ElasticGraph::GraphQL::QueryAdapter
- Inherits:
-
Object
- Object
- ElasticGraph::GraphQL::QueryAdapter
- Defined in:
- lib/elastic_graph/graphql/query_adapter/sort.rb,
lib/elastic_graph/graphql/query_adapter/filters.rb,
lib/elastic_graph/graphql/query_adapter/pagination.rb,
lib/elastic_graph/graphql/query_adapter/requested_fields.rb
Defined Under Namespace
Classes: Filters, RequestedFields
Constant Summary collapse
- Sort =
Note: This class is not tested directly but indirectly through specs on ‘QueryAdapter`
Data.define(:order_by_arg_name) do # @implements Sort def call(query:, args:, field:, lookahead:, context:) sort_clauses = field.sort_clauses_for(args[order_by_arg_name]) if sort_clauses.empty? # When there are multiple search index definitions, we just need to pick one as the # source of the default sort clauses. It doesn't really matter which (if the client # really cared, they would have provided an `order_by` argument...) but we want our # logic to be consistent and deterministic, so we just use the alphabetically first # index here. sort_clauses = (_ = query.search_index_definitions.min_by(&:name)).default_sort_clauses end query.merge_with(sort: sort_clauses) end end
- Pagination =
Note: This class is not tested directly but indirectly through specs on ‘QueryAdapter`
Data.define(:schema_element_names) do # @implements Pagination def call(query:, args:, lookahead:, field:, context:) return query unless field.type.unwrap_fully.indexed_document? document_pagination = [:first, :before, :last, :after].to_h do |key| [key, args[schema_element_names.public_send(key)]] end query.merge_with(document_pagination: document_pagination) end end