graphiti_gql 0.2.15 → 0.2.18

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: 36cf98699fc608187e70b321c60b32fc68989b5db05704fbd0f3adcdc3e7c947
4
- data.tar.gz: 1ee21e3fcce82d24027172bd106f395a797dbb4e9de8b52cbb18caf3bb41f474
3
+ metadata.gz: 90e832970f0f3329260d83e026c58493b76711ed1fbb7eee3914978014cd4684
4
+ data.tar.gz: 993170a348f371cebc8bb101c21b48ca26f6df2ef82c9422061081a6da878880
5
5
  SHA512:
6
- metadata.gz: ca86b7bba1a1c1b8e1a086872278ce730ad4e696002d45b7ebc519668294e1a0129c52da060d1a1a8673cf561f0d9d01e9c7c622b4f218316c1703fea554a5a6
7
- data.tar.gz: 2f1081e4677027d6c6bdb703c8eb59a0f702fa6e07bd0249e6f4f4ecb103bc53ae794c9025c1b8634dcb445c476fd8ce04648f841cfcf4fd4ef04667cc19800a
6
+ metadata.gz: a84908687fd25d4324b6e9d1bc9bc9ef83a3388ca49ad33c829c71828e98992b3fd04476df6d1927ea3d6f17c87b5de89bbb6aa24f60d351f101c7f69b12ec53
7
+ data.tar.gz: ad12bf08064111c18ee81b2b4006195c38311846f81310bb158126b0b89c257dabce3b60c32fe7114bace33dca19475e2af0b9d9d5976749cd1eafdcf2bf3e37
data/Gemfile.lock CHANGED
@@ -43,7 +43,7 @@ GEM
43
43
  jsonapi-serializable (~> 0.3.0)
44
44
  graphiti_errors (1.1.2)
45
45
  jsonapi-serializable (~> 0.1)
46
- graphql (2.0.11)
46
+ graphql (2.0.12)
47
47
  graphql-batch (0.5.1)
48
48
  graphql (>= 1.10, < 3)
49
49
  promise.rb (~> 0.7.2)
@@ -0,0 +1,18 @@
1
+ module GraphitiGql
2
+ class ExecutionController < GraphitiGql.config.application_controller
3
+ def execute
4
+ params = request.params # avoid strong_parameters
5
+ variables = params[:variables] || {}
6
+ result = GraphitiGql.run params[:query],
7
+ params[:variables],
8
+ graphql_context
9
+ render json: result
10
+ end
11
+
12
+ private
13
+
14
+ def default_context
15
+ defined?(:current_user)
16
+ end
17
+ end
18
+ end
@@ -26,6 +26,8 @@ module GraphitiGql
26
26
  else
27
27
  hash[key] = Node.new(value, sideload.resource.class)
28
28
  end
29
+ else
30
+ hash[key] = Node.new(value)
29
31
  end
30
32
  end
31
33
  end
@@ -199,9 +201,11 @@ module GraphitiGql
199
201
  if sideload_fields.blank?
200
202
  sideload_fields = @resource.sideload(inc.to_sym).resource.attributes.select { |_, config| config[:readable] }.map(&:first)
201
203
  end
204
+ sideload_fields = sideload_fields.map { |sf| sf.to_s.camelize(:lower) }
205
+ sideload_fields |= [:__typename]
202
206
  sideload_fields.each do |name|
203
207
  q << %|
204
- #{indent}#{name.to_s.camelize(:lower)}|
208
+ #{indent}#{name}|
205
209
  end
206
210
 
207
211
  if to_one
@@ -3,41 +3,10 @@ module GraphitiGql
3
3
  isolate_namespace GraphitiGql
4
4
 
5
5
  # TODO improvable?
6
- config.after_initialize do
6
+ config.to_prepare do
7
7
  # initializer "graphiti_gql.generate_schema" do
8
8
  Dir.glob("#{Rails.root}/app/resources/**/*").each { |f| require(f) }
9
9
  GraphitiGql.schema!
10
10
  end
11
-
12
- module ControllerContext
13
- def graphql_context
14
- ctx = { controller: self }
15
- ctx[:current_user] = current_user if respond_to?(:current_user)
16
- ctx
17
- end
18
- end
19
-
20
- initializer "graphiti_gql.define_controller" do
21
- app_controller = GraphitiGql.config.application_controller || ::ApplicationController
22
- app_controller.send(:include, ControllerContext)
23
-
24
- # rubocop:disable Lint/ConstantDefinitionInBlock(Standard)
25
- class GraphitiGql::ExecutionController < app_controller
26
- def execute
27
- params = request.params # avoid strong_parameters
28
- variables = params[:variables] || {}
29
- result = GraphitiGql.run params[:query],
30
- params[:variables],
31
- graphql_context
32
- render json: result
33
- end
34
-
35
- private
36
-
37
- def default_context
38
- defined?(:current_user)
39
- end
40
- end
41
- end
42
11
  end
43
- end
12
+ end
@@ -68,6 +68,14 @@ module GraphitiGql
68
68
  end
69
69
  end
70
70
 
71
+ def filter(name, *args, &blk)
72
+ super
73
+ opts = args.extract_options!
74
+ if opts[:if]
75
+ attributes[name][:filterable] = opts[:if]
76
+ end
77
+ end
78
+
71
79
  def filter_group(filter_names, *args)
72
80
  if filter_names.blank?
73
81
  config[:grouped_filters] = {}
@@ -22,7 +22,7 @@ module GraphitiGql
22
22
 
23
23
  def define_entrypoints
24
24
  registry.resource_types.each do |registered|
25
- if GraphitiGql.entrypoint?(registered[:resource])
25
+ if registered[:resource].graphql_entrypoint
26
26
  Fields::Index.new(registered).apply(@query_class)
27
27
  Fields::Show.new(registered).apply(@query_class)
28
28
  end
@@ -84,6 +84,7 @@ module GraphitiGql
84
84
  end
85
85
 
86
86
  def run!
87
+ @json = nil
87
88
  @result = run.call
88
89
  end
89
90
 
@@ -1,3 +1,3 @@
1
1
  module GraphitiGql
2
- VERSION = "0.2.15"
2
+ VERSION = "0.2.18"
3
3
  end
data/lib/graphiti_gql.rb CHANGED
@@ -53,16 +53,8 @@ module GraphitiGql
53
53
  yield config
54
54
  end
55
55
 
56
- def self.entrypoints=(val)
57
- @entrypoints = val
58
- end
59
-
60
- def self.entrypoints
61
- @entrypoints
62
- end
63
-
64
56
  def self.entrypoint?(resource)
65
- @entrypoints.nil? || @entrypoints.include?(resource)
57
+ !!resource.graphql_entrypoint
66
58
  end
67
59
 
68
60
  def self.run(query_string, variables = {}, context = {})
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphiti_gql
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.15
4
+ version: 0.2.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lee Richmond
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-07-26 00:00:00.000000000 Z
11
+ date: 2022-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graphql
@@ -108,7 +108,7 @@ dependencies:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '7.0'
111
- description:
111
+ description:
112
112
  email:
113
113
  - richmolj@gmail.com
114
114
  executables: []
@@ -124,6 +124,7 @@ files:
124
124
  - LICENSE.txt
125
125
  - README.md
126
126
  - Rakefile
127
+ - app/controllers/graphiti_gql/execution_controller.rb
127
128
  - bin/bundle
128
129
  - bin/byebug
129
130
  - bin/coderay
@@ -170,7 +171,7 @@ licenses:
170
171
  - MIT
171
172
  metadata:
172
173
  homepage_uri: https://www.graphiti.dev
173
- post_install_message:
174
+ post_install_message:
174
175
  rdoc_options: []
175
176
  require_paths:
176
177
  - lib
@@ -185,8 +186,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
185
186
  - !ruby/object:Gem::Version
186
187
  version: '0'
187
188
  requirements: []
188
- rubygems_version: 3.3.7
189
- signing_key:
189
+ rubygems_version: 3.0.3.1
190
+ signing_key:
190
191
  specification_version: 4
191
192
  summary: GraphQL support for Graphiti
192
193
  test_files: []