graphiti_gql 0.2.15 → 0.2.16

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: 535af0267b130ee480022a9058880a17f742ec6aa2209cc2b1d9991a82f9afbc
4
+ data.tar.gz: 43c9d8f5c3ff6147776d71741a2a24996b300fa75c3c495f2a4cb00fb11a14ca
5
5
  SHA512:
6
- metadata.gz: ca86b7bba1a1c1b8e1a086872278ce730ad4e696002d45b7ebc519668294e1a0129c52da060d1a1a8673cf561f0d9d01e9c7c622b4f218316c1703fea554a5a6
7
- data.tar.gz: 2f1081e4677027d6c6bdb703c8eb59a0f702fa6e07bd0249e6f4f4ecb103bc53ae794c9025c1b8634dcb445c476fd8ce04648f841cfcf4fd4ef04667cc19800a
6
+ metadata.gz: f5a0ea00caf0626444fd452c6502c07367cca9f579b561fd97ef2f615a6467fb415c82de9782f8d2640b567f9aeea90495e5cebb19533b564b2282afed25846b
7
+ data.tar.gz: 7cdf9e78135dd6257ec9226256d7242af74347762a4d22e4b7f1563f330fd0245b0326e164177fea524338d6c7b95f63f6c29bf13fa7e8e267aabe12affc325a
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)
@@ -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
@@ -9,34 +9,20 @@ module GraphitiGql
9
9
  GraphitiGql.schema!
10
10
  end
11
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
12
  initializer "graphiti_gql.define_controller" do
21
13
  app_controller = GraphitiGql.config.application_controller || ::ApplicationController
22
- app_controller.send(:include, ControllerContext)
23
14
 
24
15
  # rubocop:disable Lint/ConstantDefinitionInBlock(Standard)
25
16
  class GraphitiGql::ExecutionController < app_controller
26
17
  def execute
27
18
  params = request.params # avoid strong_parameters
28
19
  variables = params[:variables] || {}
20
+ ctx = respond_to?(:graphql_context) ? graphql_context : {}
29
21
  result = GraphitiGql.run params[:query],
30
22
  params[:variables],
31
- graphql_context
23
+ ctx
32
24
  render json: result
33
25
  end
34
-
35
- private
36
-
37
- def default_context
38
- defined?(:current_user)
39
- end
40
26
  end
41
27
  end
42
28
  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.16"
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,7 +1,7 @@
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.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lee Richmond