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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e50aa66c6cf3fda89d96665c6f2fc61fa92db821b4d00461101970d72c24eea6
4
- data.tar.gz: 1e058e770b73378802fd43b3e852720d9cfa9b5b80cfc77c40ea1e2e2ea602df
3
+ metadata.gz: d786f75270cbe5652b90aaff1a9b3fedb993a7b9d5428c53a97c9ff98a4502d2
4
+ data.tar.gz: 9781d093ab340bfbe489098bc88c0054868f353b5e63073279c454b36ae44764
5
5
  SHA512:
6
- metadata.gz: 7ecb9fda5f17d3414b2ae8a39f5e9fddb40f34ed683fc9d966c1098bd86f93422e9ee77439c8f27faed1384ab5876ee67bbfc296980f314c7f656930edee3734
7
- data.tar.gz: f00540102b8cccd704a2ef2d6b7cb787c750f23858b78e425e1dc59e452065b16c9d8788065c0a0c2e87a653fac70d803f743f72ead06405f207e549e0f8e132
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.12)
4
+ graphiti_graphql (0.1.15)
5
5
  activesupport (>= 4.1)
6
- graphiti (~> 1.3.2)
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.9)
26
+ concurrent-ruby (1.1.10)
27
27
  diff-lcs (1.4.4)
28
- dry-configurable (0.12.1)
28
+ dry-configurable (0.15.0)
29
29
  concurrent-ruby (~> 1.0)
30
- dry-core (~> 0.5, >= 0.5.0)
31
- dry-container (0.8.0)
30
+ dry-core (~> 0.6)
31
+ dry-container (0.9.0)
32
32
  concurrent-ruby (~> 1.0)
33
- dry-configurable (~> 0.1, >= 0.1.3)
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.2)
48
- activesupport (>= 4.1)
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.8.10)
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.14.4)
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.2)
120
+ zeitwerk (2.5.4)
121
121
 
122
122
  PLATFORMS
123
123
  ruby
data/README.md CHANGED
@@ -50,6 +50,8 @@ And then in `config/application.rb`:
50
50
  # require "sprockets/railtie"
51
51
  ```
52
52
 
53
+ Alternatively, follow [this comment](https://github.com/rmosolgo/graphiql-rails/issues/53#issuecomment-877819958).
54
+
53
55
  ## Usage
54
56
 
55
57
  #### Blending with graphql-ruby
@@ -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.2"
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
- when 6 then ::Rails.application.reloader
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
- app_controller = GraphitiGraphQL.config.federation_application_controller || ::ApplicationController
68
- # rubocop:disable Lint/ConstantDefinitionInBlock(Standard)
69
- class GraphitiGraphQL::ExecutionController < app_controller
70
- register_exception Graphiti::Errors::UnreadableAttribute, message: true
71
- def execute
72
- params = request.params # avoid strong_parameters
73
- render json: Graphiti.gql(params[:query], params[:variables])
74
- end
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(relationship_name, foreign_key: nil, magic: true, &blk)
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
- magic: magic,
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:, magic: true, foreign_key: nil, &blk)
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 magic
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
- attribute foreign_key, :integer,
53
- only: [:readable, :filterable],
54
- schema: false,
55
- readable: :gql?,
56
- filterable: :gql?
57
- elsif has_filter && !attribute
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
@@ -1,3 +1,3 @@
1
1
  module GraphitiGraphQL
2
- VERSION = "0.1.12"
2
+ VERSION = "0.1.16"
3
3
  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.12
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: 2021-08-31 00:00:00.000000000 Z
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.2
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.2
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.2.22
277
+ rubygems_version: 3.3.7
278
278
  signing_key:
279
279
  specification_version: 4
280
280
  summary: GraphQL support for Graphiti