elasticgraph-graphql 0.18.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +3 -0
- data/elasticgraph-graphql.gemspec +23 -0
- data/lib/elastic_graph/graphql/aggregation/composite_grouping_adapter.rb +79 -0
- data/lib/elastic_graph/graphql/aggregation/computation.rb +39 -0
- data/lib/elastic_graph/graphql/aggregation/date_histogram_grouping.rb +83 -0
- data/lib/elastic_graph/graphql/aggregation/field_path_encoder.rb +47 -0
- data/lib/elastic_graph/graphql/aggregation/field_term_grouping.rb +26 -0
- data/lib/elastic_graph/graphql/aggregation/key.rb +87 -0
- data/lib/elastic_graph/graphql/aggregation/nested_sub_aggregation.rb +37 -0
- data/lib/elastic_graph/graphql/aggregation/non_composite_grouping_adapter.rb +129 -0
- data/lib/elastic_graph/graphql/aggregation/path_segment.rb +31 -0
- data/lib/elastic_graph/graphql/aggregation/query.rb +172 -0
- data/lib/elastic_graph/graphql/aggregation/query_adapter.rb +345 -0
- data/lib/elastic_graph/graphql/aggregation/query_optimizer.rb +187 -0
- data/lib/elastic_graph/graphql/aggregation/resolvers/aggregated_values.rb +41 -0
- data/lib/elastic_graph/graphql/aggregation/resolvers/count_detail.rb +44 -0
- data/lib/elastic_graph/graphql/aggregation/resolvers/grouped_by.rb +30 -0
- data/lib/elastic_graph/graphql/aggregation/resolvers/node.rb +64 -0
- data/lib/elastic_graph/graphql/aggregation/resolvers/relay_connection_builder.rb +83 -0
- data/lib/elastic_graph/graphql/aggregation/resolvers/sub_aggregations.rb +82 -0
- data/lib/elastic_graph/graphql/aggregation/script_term_grouping.rb +32 -0
- data/lib/elastic_graph/graphql/aggregation/term_grouping.rb +118 -0
- data/lib/elastic_graph/graphql/client.rb +43 -0
- data/lib/elastic_graph/graphql/config.rb +81 -0
- data/lib/elastic_graph/graphql/datastore_query/document_paginator.rb +100 -0
- data/lib/elastic_graph/graphql/datastore_query/index_expression_builder.rb +142 -0
- data/lib/elastic_graph/graphql/datastore_query/paginator.rb +199 -0
- data/lib/elastic_graph/graphql/datastore_query/routing_picker.rb +239 -0
- data/lib/elastic_graph/graphql/datastore_query.rb +372 -0
- data/lib/elastic_graph/graphql/datastore_response/document.rb +78 -0
- data/lib/elastic_graph/graphql/datastore_response/search_response.rb +79 -0
- data/lib/elastic_graph/graphql/datastore_search_router.rb +151 -0
- data/lib/elastic_graph/graphql/decoded_cursor.rb +120 -0
- data/lib/elastic_graph/graphql/filtering/boolean_query.rb +45 -0
- data/lib/elastic_graph/graphql/filtering/field_path.rb +81 -0
- data/lib/elastic_graph/graphql/filtering/filter_args_translator.rb +58 -0
- data/lib/elastic_graph/graphql/filtering/filter_interpreter.rb +526 -0
- data/lib/elastic_graph/graphql/filtering/filter_value_set_extractor.rb +148 -0
- data/lib/elastic_graph/graphql/filtering/range_query.rb +56 -0
- data/lib/elastic_graph/graphql/http_endpoint.rb +229 -0
- data/lib/elastic_graph/graphql/monkey_patches/schema_field.rb +56 -0
- data/lib/elastic_graph/graphql/monkey_patches/schema_object.rb +48 -0
- data/lib/elastic_graph/graphql/query_adapter/filters.rb +161 -0
- data/lib/elastic_graph/graphql/query_adapter/pagination.rb +27 -0
- data/lib/elastic_graph/graphql/query_adapter/requested_fields.rb +124 -0
- data/lib/elastic_graph/graphql/query_adapter/sort.rb +32 -0
- data/lib/elastic_graph/graphql/query_details_tracker.rb +60 -0
- data/lib/elastic_graph/graphql/query_executor.rb +200 -0
- data/lib/elastic_graph/graphql/resolvers/get_record_field_value.rb +49 -0
- data/lib/elastic_graph/graphql/resolvers/graphql_adapter.rb +114 -0
- data/lib/elastic_graph/graphql/resolvers/list_records.rb +29 -0
- data/lib/elastic_graph/graphql/resolvers/nested_relationships.rb +74 -0
- data/lib/elastic_graph/graphql/resolvers/query_adapter.rb +85 -0
- data/lib/elastic_graph/graphql/resolvers/query_source.rb +46 -0
- data/lib/elastic_graph/graphql/resolvers/relay_connection/array_adapter.rb +71 -0
- data/lib/elastic_graph/graphql/resolvers/relay_connection/generic_adapter.rb +65 -0
- data/lib/elastic_graph/graphql/resolvers/relay_connection/page_info.rb +82 -0
- data/lib/elastic_graph/graphql/resolvers/relay_connection/search_response_adapter_builder.rb +40 -0
- data/lib/elastic_graph/graphql/resolvers/relay_connection.rb +42 -0
- data/lib/elastic_graph/graphql/resolvers/resolvable_value.rb +56 -0
- data/lib/elastic_graph/graphql/scalar_coercion_adapters/cursor.rb +35 -0
- data/lib/elastic_graph/graphql/scalar_coercion_adapters/date.rb +64 -0
- data/lib/elastic_graph/graphql/scalar_coercion_adapters/date_time.rb +60 -0
- data/lib/elastic_graph/graphql/scalar_coercion_adapters/local_time.rb +30 -0
- data/lib/elastic_graph/graphql/scalar_coercion_adapters/longs.rb +47 -0
- data/lib/elastic_graph/graphql/scalar_coercion_adapters/no_op.rb +24 -0
- data/lib/elastic_graph/graphql/scalar_coercion_adapters/time_zone.rb +44 -0
- data/lib/elastic_graph/graphql/scalar_coercion_adapters/untyped.rb +32 -0
- data/lib/elastic_graph/graphql/scalar_coercion_adapters/valid_time_zones.rb +634 -0
- data/lib/elastic_graph/graphql/schema/arguments.rb +78 -0
- data/lib/elastic_graph/graphql/schema/enum_value.rb +30 -0
- data/lib/elastic_graph/graphql/schema/field.rb +147 -0
- data/lib/elastic_graph/graphql/schema/relation_join.rb +103 -0
- data/lib/elastic_graph/graphql/schema/type.rb +263 -0
- data/lib/elastic_graph/graphql/schema.rb +164 -0
- data/lib/elastic_graph/graphql.rb +253 -0
- data/script/dump_time_zones +81 -0
- data/script/dump_time_zones.java +17 -0
- metadata +503 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Copyright 2024 Block, Inc.
|
|
2
|
+
#
|
|
3
|
+
# Use of this source code is governed by an MIT-style
|
|
4
|
+
# license that can be found in the LICENSE file or at
|
|
5
|
+
# https://opensource.org/licenses/MIT.
|
|
6
|
+
#
|
|
7
|
+
# frozen_string_literal: true
|
|
8
|
+
|
|
9
|
+
require "elastic_graph/constants"
|
|
10
|
+
|
|
11
|
+
module ElasticGraph
|
|
12
|
+
class GraphQL
|
|
13
|
+
module ScalarCoercionAdapters
|
|
14
|
+
class LocalTime
|
|
15
|
+
def self.coerce_input(value, ctx)
|
|
16
|
+
validated_value(value) || raise(::GraphQL::CoercionError,
|
|
17
|
+
"Could not coerce value #{value.inspect} to LocalTime: must be formatted as an RFC3339 partial time (such as `14:23:12` or `07:05:23.555`")
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def self.coerce_result(value, ctx)
|
|
21
|
+
validated_value(value)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
private_class_method def self.validated_value(value)
|
|
25
|
+
value if value.is_a?(::String) && VALID_LOCAL_TIME_REGEX.match?(value)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Copyright 2024 Block, Inc.
|
|
2
|
+
#
|
|
3
|
+
# Use of this source code is governed by an MIT-style
|
|
4
|
+
# license that can be found in the LICENSE file or at
|
|
5
|
+
# https://opensource.org/licenses/MIT.
|
|
6
|
+
#
|
|
7
|
+
# frozen_string_literal: true
|
|
8
|
+
|
|
9
|
+
require "elastic_graph/constants"
|
|
10
|
+
|
|
11
|
+
module ElasticGraph
|
|
12
|
+
class GraphQL
|
|
13
|
+
module ScalarCoercionAdapters
|
|
14
|
+
class Longs
|
|
15
|
+
def self.to_ruby_int_in_range(value, min, max)
|
|
16
|
+
value = Integer(value, exception: false)
|
|
17
|
+
return nil if value.nil? || value > max || value < min
|
|
18
|
+
value
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
class JsonSafeLong
|
|
23
|
+
def self.coerce_input(value, ctx)
|
|
24
|
+
Longs.to_ruby_int_in_range(value, JSON_SAFE_LONG_MIN, JSON_SAFE_LONG_MAX)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def self.coerce_result(value, ctx)
|
|
28
|
+
Longs.to_ruby_int_in_range(value, JSON_SAFE_LONG_MIN, JSON_SAFE_LONG_MAX)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
class LongString
|
|
33
|
+
def self.coerce_input(value, ctx)
|
|
34
|
+
# Do not allow non-string input, to guard against the value potentially having been rounded off by
|
|
35
|
+
# the client before it got serialized into a JSON request.
|
|
36
|
+
return nil unless value.is_a?(::String)
|
|
37
|
+
|
|
38
|
+
Longs.to_ruby_int_in_range(value, LONG_STRING_MIN, LONG_STRING_MAX)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def self.coerce_result(value, ctx)
|
|
42
|
+
Longs.to_ruby_int_in_range(value, LONG_STRING_MIN, LONG_STRING_MAX)&.to_s
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Copyright 2024 Block, Inc.
|
|
2
|
+
#
|
|
3
|
+
# Use of this source code is governed by an MIT-style
|
|
4
|
+
# license that can be found in the LICENSE file or at
|
|
5
|
+
# https://opensource.org/licenses/MIT.
|
|
6
|
+
#
|
|
7
|
+
# frozen_string_literal: true
|
|
8
|
+
|
|
9
|
+
module ElasticGraph
|
|
10
|
+
class GraphQL
|
|
11
|
+
module ScalarCoercionAdapters
|
|
12
|
+
# No-op implementation of coercion interface. Used as the default adapter.
|
|
13
|
+
class NoOp
|
|
14
|
+
def self.coerce_input(value, ctx)
|
|
15
|
+
value
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def self.coerce_result(value, ctx)
|
|
19
|
+
value
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Copyright 2024 Block, Inc.
|
|
2
|
+
#
|
|
3
|
+
# Use of this source code is governed by an MIT-style
|
|
4
|
+
# license that can be found in the LICENSE file or at
|
|
5
|
+
# https://opensource.org/licenses/MIT.
|
|
6
|
+
#
|
|
7
|
+
# frozen_string_literal: true
|
|
8
|
+
|
|
9
|
+
require "did_you_mean"
|
|
10
|
+
require "elastic_graph/graphql/scalar_coercion_adapters/valid_time_zones"
|
|
11
|
+
|
|
12
|
+
module ElasticGraph
|
|
13
|
+
class GraphQL
|
|
14
|
+
module ScalarCoercionAdapters
|
|
15
|
+
class TimeZone
|
|
16
|
+
SUGGESTER = ::DidYouMean::SpellChecker.new(dictionary: VALID_TIME_ZONES.to_a)
|
|
17
|
+
|
|
18
|
+
def self.coerce_input(value, ctx)
|
|
19
|
+
return value if value.nil? || VALID_TIME_ZONES.include?(value)
|
|
20
|
+
|
|
21
|
+
suggestions = SUGGESTER.correct(value).map(&:inspect)
|
|
22
|
+
suggestion_sentence =
|
|
23
|
+
if suggestions.size >= 3
|
|
24
|
+
*initial, final = suggestions
|
|
25
|
+
" Possible alternatives: #{initial.join(", ")}, or #{final}."
|
|
26
|
+
elsif suggestions.size == 1
|
|
27
|
+
" Possible alternative: #{suggestions.first}."
|
|
28
|
+
elsif suggestions.size > 0
|
|
29
|
+
" Possible alternatives: #{suggestions.join(" or ")}."
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
raise ::GraphQL::CoercionError,
|
|
33
|
+
"Could not coerce value #{value.inspect} to TimeZone: must be a valid IANA time zone identifier " \
|
|
34
|
+
"(such as `America/Los_Angeles` or `UTC`).#{suggestion_sentence}"
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def self.coerce_result(value, ctx)
|
|
38
|
+
return value if value.nil? || VALID_TIME_ZONES.include?(value)
|
|
39
|
+
nil
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Copyright 2024 Block, Inc.
|
|
2
|
+
#
|
|
3
|
+
# Use of this source code is governed by an MIT-style
|
|
4
|
+
# license that can be found in the LICENSE file or at
|
|
5
|
+
# https://opensource.org/licenses/MIT.
|
|
6
|
+
#
|
|
7
|
+
# frozen_string_literal: true
|
|
8
|
+
|
|
9
|
+
require "elastic_graph/support/untyped_encoder"
|
|
10
|
+
|
|
11
|
+
module ElasticGraph
|
|
12
|
+
class GraphQL
|
|
13
|
+
module ScalarCoercionAdapters
|
|
14
|
+
class Untyped
|
|
15
|
+
def self.coerce_input(value, ctx)
|
|
16
|
+
Support::UntypedEncoder.encode(value).tap do |encoded|
|
|
17
|
+
# Check to see if the encoded form, when parsed as JSON, gives us back the original value. If not,
|
|
18
|
+
# it's not a valid `Untyped` value!
|
|
19
|
+
if Support::UntypedEncoder.decode(encoded) != value
|
|
20
|
+
raise ::GraphQL::CoercionError,
|
|
21
|
+
"Could not coerce value #{value.inspect} to `Untyped`: not representable as JSON."
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def self.coerce_result(value, ctx)
|
|
27
|
+
Support::UntypedEncoder.decode(value) if value.is_a?(::String)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|