graphiti_gql 0.2.14 → 0.2.17

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: 5a4faaf029a4624626f9bfa68815734bc6571381fa6b2d153830df1825c2d61f
4
- data.tar.gz: 2f73a19e8b84280c83bc7d6ab0f574ffb5d4b2fb6b7328ca75de6d47a145ecc0
3
+ metadata.gz: 18a776555ead439b1ddfb5ff28835e1da6c5673b93287379d3cd8de4d366d5b7
4
+ data.tar.gz: 919983d1eb5ad3653b4a95d22d9ed0f1d46d159fce21b2095746118e7e3bd175
5
5
  SHA512:
6
- metadata.gz: d00b4b5b4e2314efd6e1d4ff6b72a357ba582a045dcab28214596130054fc8e15b22b8267fa1157e1746ddceda7c0b25602a0441ccaa82b4bda29fa27aab412c
7
- data.tar.gz: 7a6d2a5ee610af959d292e87c492aa770ff2ab2d0546339dc3f30236811a3b44ab7edf9110773c457707d19bb0d06c9b62884a69ea94c13ad90d227eb8540bce
6
+ metadata.gz: e70f2ee088082aae875d1f98117e65f9a2daf1c08a752ea79142b3ca371c30c64333b75d4e54d890356a62cc11dcef8a6c7d214936b9ffa94241c893ec672cfb
7
+ data.tar.gz: 29c371f94406f5b37beb82e6e440f5f52b3bca2345f2cc7b719ecea5f67ce28333a25820c6fd46f87ca540a218e18a6bd24e67e862f1fd6db66ab53203b1241b
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- graphiti_gql (0.2.9)
4
+ graphiti_gql (0.2.15)
5
5
  graphiti (~> 1.3.9)
6
6
  graphql (~> 2.0)
7
7
  graphql-batch (~> 0.5)
@@ -20,15 +20,11 @@ GEM
20
20
  coderay (1.1.3)
21
21
  concurrent-ruby (1.1.10)
22
22
  diff-lcs (1.5.0)
23
- dry-configurable (0.15.0)
23
+ dry-container (0.10.0)
24
24
  concurrent-ruby (~> 1.0)
25
- dry-core (~> 0.6)
26
- dry-container (0.9.0)
25
+ dry-core (0.8.0)
27
26
  concurrent-ruby (~> 1.0)
28
- dry-configurable (~> 0.13, >= 0.13.0)
29
- dry-core (0.7.1)
30
- concurrent-ruby (~> 1.0)
31
- dry-inflector (0.2.1)
27
+ dry-inflector (0.3.0)
32
28
  dry-logic (1.2.0)
33
29
  concurrent-ruby (~> 1.0)
34
30
  dry-core (~> 0.5, >= 0.5)
@@ -47,7 +43,7 @@ GEM
47
43
  jsonapi-serializable (~> 0.3.0)
48
44
  graphiti_errors (1.1.2)
49
45
  jsonapi-serializable (~> 0.1)
50
- graphql (2.0.11)
46
+ graphql (2.0.12)
51
47
  graphql-batch (0.5.1)
52
48
  graphql (>= 1.10, < 3)
53
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
@@ -3,42 +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
- require "#{Rails.root}/app/controllers/application_controller"
22
- app_controller = GraphitiGql.config.application_controller || ::ApplicationController
23
- app_controller.send(:include, ControllerContext)
24
-
25
- # rubocop:disable Lint/ConstantDefinitionInBlock(Standard)
26
- class GraphitiGql::ExecutionController < app_controller
27
- def execute
28
- params = request.params # avoid strong_parameters
29
- variables = params[:variables] || {}
30
- result = GraphitiGql.run params[:query],
31
- params[:variables],
32
- graphql_context
33
- render json: result
34
- end
35
-
36
- private
37
-
38
- def default_context
39
- defined?(:current_user)
40
- end
41
- end
42
- end
43
11
  end
44
- 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.14"
2
+ VERSION = "0.2.17"
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.14
4
+ version: 0.2.17
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-24 00:00:00.000000000 Z
11
+ date: 2022-07-28 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: []