graphiti_graphql 0.1.11 → 0.1.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3572b13acb369033180b7ab0e4bba6f610d069302dfb3efab30fb4af890ad758
4
- data.tar.gz: 522d580599507c14ca4b477be3787905cf7574b7f9ca487418108ae0afc08cd5
3
+ metadata.gz: e50aa66c6cf3fda89d96665c6f2fc61fa92db821b4d00461101970d72c24eea6
4
+ data.tar.gz: 1e058e770b73378802fd43b3e852720d9cfa9b5b80cfc77c40ea1e2e2ea602df
5
5
  SHA512:
6
- metadata.gz: 697d98b5580457160179f895ded0fd81738c7714773636a9850ecab3b131ca6bab9a4e916c131f7a29519631a7333640135870f2d95d4c14aa2916c67c00b68d
7
- data.tar.gz: 2cc559be1dc33bf52056d1be94e6a3a0cb88a4de240bcd19603dd1661e2f27c6504d1cc315c8ab5b888828868857fb05c9bb535353793ed810cbbd84924e2968
6
+ metadata.gz: 7ecb9fda5f17d3414b2ae8a39f5e9fddb40f34ed683fc9d966c1098bd86f93422e9ee77439c8f27faed1384ab5876ee67bbfc296980f314c7f656930edee3734
7
+ data.tar.gz: f00540102b8cccd704a2ef2d6b7cb787c750f23858b78e425e1dc59e452065b16c9d8788065c0a0c2e87a653fac70d803f743f72ead06405f207e549e0f8e132
data/Gemfile.lock CHANGED
@@ -1,17 +1,17 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- graphiti_graphql (0.1.10)
4
+ graphiti_graphql (0.1.12)
5
5
  activesupport (>= 4.1)
6
- graphiti (~> 1.3)
6
+ graphiti (~> 1.3.2)
7
7
  graphql (~> 1.12)
8
8
 
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- activemodel (6.1.1)
13
- activesupport (= 6.1.1)
14
- activesupport (6.1.1)
12
+ activemodel (6.1.4.1)
13
+ activesupport (= 6.1.4.1)
14
+ activesupport (6.1.4.1)
15
15
  concurrent-ruby (~> 1.0, >= 1.0.2)
16
16
  i18n (>= 1.6, < 2)
17
17
  minitest (>= 5.1)
@@ -23,7 +23,7 @@ GEM
23
23
  ast (2.4.2)
24
24
  byebug (11.1.3)
25
25
  coderay (1.1.3)
26
- concurrent-ruby (1.1.8)
26
+ concurrent-ruby (1.1.9)
27
27
  diff-lcs (1.4.4)
28
28
  dry-configurable (0.12.1)
29
29
  concurrent-ruby (~> 1.0)
@@ -43,8 +43,8 @@ GEM
43
43
  dry-core (~> 0.5, >= 0.5)
44
44
  dry-inflector (~> 0.1, >= 0.1.2)
45
45
  dry-logic (~> 1.0, >= 1.0.2)
46
- google-protobuf (3.15.2)
47
- graphiti (1.3.0)
46
+ google-protobuf (3.17.3)
47
+ graphiti (1.3.2)
48
48
  activesupport (>= 4.1)
49
49
  concurrent-ruby (~> 1.0)
50
50
  dry-types (>= 0.15.0, < 2.0)
@@ -56,11 +56,11 @@ GEM
56
56
  graphiti_spec_helpers (1.0.5)
57
57
  graphiti (>= 1.0.alpha.1)
58
58
  rspec (~> 3.0)
59
- graphql (1.12.3)
59
+ graphql (1.12.15)
60
60
  graphql-batch (0.4.3)
61
61
  graphql (>= 1.3, < 2)
62
62
  promise.rb (~> 0.7.2)
63
- i18n (1.8.9)
63
+ i18n (1.8.10)
64
64
  concurrent-ruby (~> 1.0)
65
65
  jsonapi-renderer (0.2.2)
66
66
  jsonapi-serializable (0.3.1)
@@ -68,18 +68,18 @@ GEM
68
68
  method_source (1.0.0)
69
69
  minitest (5.14.4)
70
70
  parallel (1.20.1)
71
- parser (3.0.0.0)
71
+ parser (3.0.2.0)
72
72
  ast (~> 2.4.1)
73
73
  promise.rb (0.7.4)
74
- pry (0.13.1)
74
+ pry (0.14.1)
75
75
  coderay (~> 1.1)
76
76
  method_source (~> 1.0)
77
- pry-byebug (3.9.0)
77
+ pry-byebug (3.8.0)
78
78
  byebug (~> 11.0)
79
- pry (~> 0.13.0)
79
+ pry (~> 0.10)
80
80
  rainbow (3.0.0)
81
81
  rake (10.5.0)
82
- regexp_parser (2.0.3)
82
+ regexp_parser (2.1.1)
83
83
  rexml (3.2.5)
84
84
  rspec (3.10.0)
85
85
  rspec-core (~> 3.10.0)
@@ -94,24 +94,24 @@ GEM
94
94
  diff-lcs (>= 1.2.0, < 2.0)
95
95
  rspec-support (~> 3.10.0)
96
96
  rspec-support (3.10.2)
97
- rubocop (1.8.1)
97
+ rubocop (1.20.0)
98
98
  parallel (~> 1.10)
99
99
  parser (>= 3.0.0.0)
100
100
  rainbow (>= 2.2.2, < 4.0)
101
101
  regexp_parser (>= 1.8, < 3.0)
102
102
  rexml
103
- rubocop-ast (>= 1.2.0, < 2.0)
103
+ rubocop-ast (>= 1.9.1, < 2.0)
104
104
  ruby-progressbar (~> 1.7)
105
105
  unicode-display_width (>= 1.4.0, < 3.0)
106
- rubocop-ast (1.4.1)
107
- parser (>= 2.7.1.5)
108
- rubocop-performance (1.9.2)
109
- rubocop (>= 0.90.0, < 2.0)
106
+ rubocop-ast (1.11.0)
107
+ parser (>= 3.0.1.1)
108
+ rubocop-performance (1.11.5)
109
+ rubocop (>= 1.7.0, < 2.0)
110
110
  rubocop-ast (>= 0.4.0)
111
111
  ruby-progressbar (1.11.0)
112
- standard (0.12.0)
113
- rubocop (= 1.8.1)
114
- rubocop-performance (= 1.9.2)
112
+ standard (1.3.0)
113
+ rubocop (= 1.20.0)
114
+ rubocop-performance (= 1.11.5)
115
115
  standardrb (1.0.0)
116
116
  standard
117
117
  tzinfo (2.0.4)
@@ -137,4 +137,4 @@ DEPENDENCIES
137
137
  standardrb
138
138
 
139
139
  BUNDLED WITH
140
- 2.2.16
140
+ 2.2.25
@@ -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.2"
31
31
  spec.add_dependency "activesupport", ">= 4.1"
32
32
  spec.add_dependency "graphql", "~> 1.12"
33
33
 
@@ -7,10 +7,11 @@ module GraphitiGraphQL
7
7
  @type_name = type_name
8
8
  end
9
9
 
10
- def has_many(relationship_name, foreign_key: nil, &blk)
10
+ def has_many(relationship_name, foreign_key: nil, magic: true, &blk)
11
11
  @caller.federated_has_many relationship_name,
12
12
  type: @type_name,
13
13
  foreign_key: foreign_key,
14
+ magic: magic,
14
15
  &blk
15
16
  end
16
17
  end
@@ -29,14 +30,18 @@ module GraphitiGraphQL
29
30
  config[:federated_resources] ||= []
30
31
  end
31
32
 
33
+ # NB - for external use, use federated_type("Type").has_many instead
34
+ #
32
35
  # * Add to the list of external graphql-ruby types we need in schema
33
36
  # * Add a readable and filterable FK, without clobbering pre-existing
34
- def federated_has_many(name, type:, foreign_key: nil, &blk)
37
+ def federated_has_many(name, type:, magic: true, foreign_key: nil, &blk)
35
38
  foreign_key ||= :"#{type.underscore}_id"
36
39
  resource = FederatedResource.new(type)
37
40
  federated_resources << resource
38
41
  resource.add_relationship(:has_many, name, self, foreign_key, &blk)
39
42
 
43
+ return unless magic
44
+
40
45
  attribute = attributes.find { |name, config|
41
46
  name.to_sym == foreign_key &&
42
47
  !!config[:readable] &&
@@ -52,14 +52,18 @@ module GraphitiGraphQL
52
52
  @base_interface || BaseInterface
53
53
  end
54
54
 
55
- def self.generate(entrypoint_resources = nil)
55
+ def self.generate(resources: nil, entrypoints: nil)
56
56
  instance = new
57
57
  schema = Class.new(::GraphitiGraphQL.schema_class || GraphQL::Schema)
58
58
  graphiti_schema = GraphitiGraphQL::GraphitiSchema::Wrapper
59
59
  .new(Graphiti::Schema.generate)
60
60
  instance.graphiti_schema = graphiti_schema
61
+
62
+ resources ||= graphiti_schema.resources
63
+ entrypoints ||= self.entrypoints || resources
64
+
61
65
  instance.schema = schema
62
- instance.apply_query(entrypoint_resources || entrypoints)
66
+ instance.apply_query(resources, entrypoints)
63
67
  instance
64
68
  end
65
69
 
@@ -72,8 +76,8 @@ module GraphitiGraphQL
72
76
  @query_fields = {}
73
77
  end
74
78
 
75
- def apply_query(entries)
76
- query_type = generate_schema_query(entries)
79
+ def apply_query(resources, entrypoints)
80
+ query_type = generate_schema_query(resources, entrypoints)
77
81
  Federation::SchemaDecorator.decorate(self) if self.class.federation?
78
82
 
79
83
  # NB - don't call .query here of federation will break things
@@ -86,7 +90,7 @@ module GraphitiGraphQL
86
90
  schema.query # Actually fires the federation code
87
91
  end
88
92
 
89
- def generate_schema_query(entrypoint_resources = nil)
93
+ def generate_schema_query(resources, entrypoints)
90
94
  existing_query = schema.instance_variable_get(:@query)
91
95
  existing_query ||= schema.send(:find_inherited_value, :query)
92
96
  # NB - don't call graphql_schema.query here of federation will break things
@@ -97,13 +101,11 @@ module GraphitiGraphQL
97
101
 
98
102
  # Ensure all types are generated, even if they aren't in a top-level Query
99
103
  # We might now want to expose the query, but do want to federate the Type
100
- graphiti_schema.resources.each do |resource|
101
- next if resource.remote?
104
+ get_schema_resources(resources).each do |resource|
102
105
  generate_type(resource)
103
106
  end
104
107
 
105
- get_entrypoints(entrypoint_resources).each do |resource|
106
- next if resource.remote?
108
+ get_schema_resources(entrypoints).each do |resource|
107
109
  add_index(query_class, resource)
108
110
  add_show(query_class, resource)
109
111
  end
@@ -203,14 +205,14 @@ module GraphitiGraphQL
203
205
  top_level_single: true
204
206
  end
205
207
 
206
- def get_entrypoints(manually_specified)
208
+ def get_schema_resources(manually_specified)
207
209
  resources = graphiti_schema.resources
208
210
  if manually_specified
209
211
  resources = resources.select { |r|
210
212
  manually_specified.map(&:name).include?(r.name)
211
213
  }
212
214
  end
213
- resources
215
+ resources.reject(&:remote?)
214
216
  end
215
217
 
216
218
  def generate_sort_att_type_for(resource)
@@ -1,3 +1,3 @@
1
1
  module GraphitiGraphQL
2
- VERSION = "0.1.11"
2
+ VERSION = "0.1.12"
3
3
  end
@@ -53,8 +53,11 @@ module GraphitiGraphQL
53
53
  @generated ||= GraphitiGraphQL::Schema.generate
54
54
  end
55
55
 
56
- def generate!(entrypoint_resources = nil)
57
- @generated = GraphitiGraphQL::Schema.generate(entrypoint_resources)
56
+ # resources: All resources to put in the schema. Mostly just for testing.
57
+ # entrypoints: All resources to expose as top-level query objects
58
+ def generate!(resources: nil, entrypoints: nil)
59
+ @generated = GraphitiGraphQL::Schema
60
+ .generate(resources: resources, entrypoints: entrypoints)
58
61
  end
59
62
 
60
63
  def generated?
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.11
4
+ version: 0.1.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lee Richmond
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-08-16 00:00:00.000000000 Z
11
+ date: 2021-08-31 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.2
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.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activesupport
29
29
  requirement: !ruby/object:Gem::Requirement