graphiti_graphql 0.1.12 → 0.1.16
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 +4 -4
- data/Gemfile.lock +12 -12
- data/README.md +2 -0
- data/graphiti_graphql.gemspec +1 -1
- data/lib/graphiti_graphql/engine.rb +11 -9
- data/lib/graphiti_graphql/federation/resource_dsl.rb +30 -12
- data/lib/graphiti_graphql/runner.rb +1 -1
- data/lib/graphiti_graphql/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d786f75270cbe5652b90aaff1a9b3fedb993a7b9d5428c53a97c9ff98a4502d2
|
4
|
+
data.tar.gz: 9781d093ab340bfbe489098bc88c0054868f353b5e63073279c454b36ae44764
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa5dc90dde1d56a5089813f11a3fbb8b0a02a2d831e7f8d0553efc7d78dedf7d55f444a7def0f28571937652abc05158d4dc3210424c0bee182bc851ffb9f8b1
|
7
|
+
data.tar.gz: 0df39b1128f036a98faee0bfbb24e9f0245f64bb24278463ccb7437e67b950a4e4710d5098b19975010171ba8fdfd9235217b4b2326feb85c93f7ec28c12f937
|
data/Gemfile.lock
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
graphiti_graphql (0.1.
|
4
|
+
graphiti_graphql (0.1.15)
|
5
5
|
activesupport (>= 4.1)
|
6
|
-
graphiti (~> 1.3
|
6
|
+
graphiti (~> 1.3)
|
7
7
|
graphql (~> 1.12)
|
8
8
|
|
9
9
|
GEM
|
@@ -23,14 +23,14 @@ GEM
|
|
23
23
|
ast (2.4.2)
|
24
24
|
byebug (11.1.3)
|
25
25
|
coderay (1.1.3)
|
26
|
-
concurrent-ruby (1.1.
|
26
|
+
concurrent-ruby (1.1.10)
|
27
27
|
diff-lcs (1.4.4)
|
28
|
-
dry-configurable (0.
|
28
|
+
dry-configurable (0.15.0)
|
29
29
|
concurrent-ruby (~> 1.0)
|
30
|
-
dry-core (~> 0.
|
31
|
-
dry-container (0.
|
30
|
+
dry-core (~> 0.6)
|
31
|
+
dry-container (0.9.0)
|
32
32
|
concurrent-ruby (~> 1.0)
|
33
|
-
dry-configurable (~> 0.
|
33
|
+
dry-configurable (~> 0.13, >= 0.13.0)
|
34
34
|
dry-core (0.7.1)
|
35
35
|
concurrent-ruby (~> 1.0)
|
36
36
|
dry-inflector (0.2.1)
|
@@ -44,8 +44,8 @@ GEM
|
|
44
44
|
dry-inflector (~> 0.1, >= 0.1.2)
|
45
45
|
dry-logic (~> 1.0, >= 1.0.2)
|
46
46
|
google-protobuf (3.17.3)
|
47
|
-
graphiti (1.3.
|
48
|
-
activesupport (>=
|
47
|
+
graphiti (1.3.7)
|
48
|
+
activesupport (>= 5.2)
|
49
49
|
concurrent-ruby (~> 1.0)
|
50
50
|
dry-types (>= 0.15.0, < 2.0)
|
51
51
|
graphiti_errors (~> 1.1.0)
|
@@ -60,13 +60,13 @@ GEM
|
|
60
60
|
graphql-batch (0.4.3)
|
61
61
|
graphql (>= 1.3, < 2)
|
62
62
|
promise.rb (~> 0.7.2)
|
63
|
-
i18n (1.
|
63
|
+
i18n (1.10.0)
|
64
64
|
concurrent-ruby (~> 1.0)
|
65
65
|
jsonapi-renderer (0.2.2)
|
66
66
|
jsonapi-serializable (0.3.1)
|
67
67
|
jsonapi-renderer (~> 0.2.0)
|
68
68
|
method_source (1.0.0)
|
69
|
-
minitest (5.
|
69
|
+
minitest (5.15.0)
|
70
70
|
parallel (1.20.1)
|
71
71
|
parser (3.0.2.0)
|
72
72
|
ast (~> 2.4.1)
|
@@ -117,7 +117,7 @@ GEM
|
|
117
117
|
tzinfo (2.0.4)
|
118
118
|
concurrent-ruby (~> 1.0)
|
119
119
|
unicode-display_width (2.0.0)
|
120
|
-
zeitwerk (2.4
|
120
|
+
zeitwerk (2.5.4)
|
121
121
|
|
122
122
|
PLATFORMS
|
123
123
|
ruby
|
data/README.md
CHANGED
data/graphiti_graphql.gemspec
CHANGED
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
28
|
spec.require_paths = ["lib"]
|
29
29
|
|
30
|
-
spec.add_dependency "graphiti", "~> 1.3
|
30
|
+
spec.add_dependency "graphiti", "~> 1.3"
|
31
31
|
spec.add_dependency "activesupport", ">= 4.1"
|
32
32
|
spec.add_dependency "graphql", "~> 1.12"
|
33
33
|
|
@@ -21,7 +21,8 @@ module GraphitiGraphQL
|
|
21
21
|
case Rails::VERSION::MAJOR
|
22
22
|
when 4 then ActionDispatch::Reloader
|
23
23
|
when 5 then ActiveSupport::Reloader
|
24
|
-
|
24
|
+
else
|
25
|
+
::Rails.application.reloader
|
25
26
|
end
|
26
27
|
end
|
27
28
|
|
@@ -64,15 +65,16 @@ module GraphitiGraphQL
|
|
64
65
|
end
|
65
66
|
|
66
67
|
initializer "graphiti_graphql.define_controller" do
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
68
|
+
require "#{Rails.root}/app/controllers/application_controller"
|
69
|
+
app_controller = GraphitiGraphQL.config.federation_application_controller || ::ApplicationController
|
70
|
+
# rubocop:disable Lint/ConstantDefinitionInBlock(Standard)
|
71
|
+
class GraphitiGraphQL::ExecutionController < app_controller
|
72
|
+
register_exception Graphiti::Errors::UnreadableAttribute, message: true
|
73
|
+
def execute
|
74
|
+
params = request.params # avoid strong_parameters
|
75
|
+
render json: Graphiti.gql(params[:query], params[:variables])
|
75
76
|
end
|
77
|
+
end
|
76
78
|
end
|
77
79
|
|
78
80
|
initializer "graphiti_graphql.federation" do
|
@@ -7,11 +7,18 @@ module GraphitiGraphQL
|
|
7
7
|
@type_name = type_name
|
8
8
|
end
|
9
9
|
|
10
|
-
def has_many(
|
10
|
+
def has_many(
|
11
|
+
relationship_name,
|
12
|
+
foreign_key: nil,
|
13
|
+
field: true,
|
14
|
+
filter: true,
|
15
|
+
&blk
|
16
|
+
)
|
11
17
|
@caller.federated_has_many relationship_name,
|
12
18
|
type: @type_name,
|
13
19
|
foreign_key: foreign_key,
|
14
|
-
|
20
|
+
field: field,
|
21
|
+
filter: filter,
|
15
22
|
&blk
|
16
23
|
end
|
17
24
|
end
|
@@ -34,13 +41,13 @@ module GraphitiGraphQL
|
|
34
41
|
#
|
35
42
|
# * Add to the list of external graphql-ruby types we need in schema
|
36
43
|
# * Add a readable and filterable FK, without clobbering pre-existing
|
37
|
-
def federated_has_many(name, type:,
|
44
|
+
def federated_has_many(name, type:, filter: true, field: true, foreign_key: nil, &blk)
|
38
45
|
foreign_key ||= :"#{type.underscore}_id"
|
39
46
|
resource = FederatedResource.new(type)
|
40
47
|
federated_resources << resource
|
41
48
|
resource.add_relationship(:has_many, name, self, foreign_key, &blk)
|
42
49
|
|
43
|
-
return unless
|
50
|
+
return unless (filter || field)
|
44
51
|
|
45
52
|
attribute = attributes.find { |name, config|
|
46
53
|
name.to_sym == foreign_key &&
|
@@ -49,20 +56,31 @@ module GraphitiGraphQL
|
|
49
56
|
}
|
50
57
|
has_filter = filters.key?(foreign_key)
|
51
58
|
if !attribute && !has_filter
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
59
|
+
if field
|
60
|
+
opts = {
|
61
|
+
only: [:readable],
|
62
|
+
schema: false,
|
63
|
+
readable: :gql?
|
64
|
+
}
|
65
|
+
if filter
|
66
|
+
opts[:only] << :filterable
|
67
|
+
opts[:filterable] = :gql?
|
68
|
+
end
|
69
|
+
attribute foreign_key, :integer, opts
|
70
|
+
elsif filter
|
71
|
+
filter foreign_key, :integer, schema: false
|
72
|
+
attributes[foreign_key][:filterable] = :gql?
|
73
|
+
end
|
74
|
+
elsif has_filter && !attribute && field
|
58
75
|
prior = filters[foreign_key]
|
59
76
|
attribute foreign_key, prior[:type],
|
60
77
|
only: [:readable, :filterable],
|
61
78
|
schema: false,
|
62
79
|
readable: :gql?
|
63
80
|
filters[foreign_key] = prior
|
64
|
-
elsif attribute && !has_filter
|
65
|
-
filter foreign_key, attribute[:type]
|
81
|
+
elsif attribute && !has_filter && filter
|
82
|
+
filter foreign_key, attribute[:type], schema: false
|
83
|
+
attributes[foreign_key][:filterable] = :gql?
|
66
84
|
end
|
67
85
|
end
|
68
86
|
|
@@ -332,7 +332,7 @@ module GraphitiGraphQL
|
|
332
332
|
if stats
|
333
333
|
stat_param = {}
|
334
334
|
stats.children.each do |stat_node|
|
335
|
-
stat_name = stat_node.name
|
335
|
+
stat_name = stat_node.name.underscore
|
336
336
|
calculations = stat_node.children.map(&:name)
|
337
337
|
stat_param[stat_name.to_sym] = calculations.join(",")
|
338
338
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphiti_graphql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lee Richmond
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: graphiti
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.3
|
19
|
+
version: '1.3'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.3
|
26
|
+
version: '1.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activesupport
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -274,7 +274,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
274
274
|
- !ruby/object:Gem::Version
|
275
275
|
version: '0'
|
276
276
|
requirements: []
|
277
|
-
rubygems_version: 3.
|
277
|
+
rubygems_version: 3.3.7
|
278
278
|
signing_key:
|
279
279
|
specification_version: 4
|
280
280
|
summary: GraphQL support for Graphiti
|