rails-graphql 1.0.5 → 1.0.6

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: 5e7e0b35058deec4afd328520ed24fcd24fe4b0f8765b064b0ff0005398e9e7a
4
- data.tar.gz: 0ef41b6819bbbe8057fa203ff6f008812e385030d3c171b401ac051a5890d756
3
+ metadata.gz: d18315ad503f122d67555202db0417507d7b5d72ecf5c060396bf7974b7cf826
4
+ data.tar.gz: 3688696c6d83cd9aebe2be3024906292bbdd291f3fb4b272bb5b1841714ba10e
5
5
  SHA512:
6
- metadata.gz: 14d030f7f42f0096d30d0fe9eab85baf3b52526ad5432620a16fa2288e6cfc5e0c123b8f433c78d1155a1dc0869ce5c7567bcdd3b6ff6eef5eca3de1d13ab399
7
- data.tar.gz: 933ce0bcb53a39d436a1ff60056882d187bdcf4ec6a76b883f91724b550cdb81164a16e2bc91642db8e2093a76f3c20138ea8fa2ae92772e626352d3807f1adb
6
+ metadata.gz: 79d8b337fd5ef5caaf93a6bc8dfc4a21cc6f7f5f5633ab1b9e4076bef0c90c163792283fd2b0cd02063c3111bf2a569e4909130e04e419455a8f9c3d80dc744d
7
+ data.tar.gz: 58d5dbe146a65ed87987b05d5e00ba14bb3a22ded1ba300f27bb08ef2f36783bcabfe42f9c2550187f01d286341387ac17acec51d79ee00fccfc7a34783d5c5e
data/lib/gql_parser.so CHANGED
Binary file
@@ -131,8 +131,9 @@ module Rails
131
131
  return unless args.size.zero?
132
132
 
133
133
  if field.try(:dynamic_resolver?)
134
- prepared = prepared_data_for(field)
135
- args << Event.trigger(:resolve, field, self, prepared_data: prepared, &field.resolver)
134
+ extra = prepared_data_for(field, with_null: true)
135
+ extra = extra === PreparedData::NULL ? EMPTY_HASH : { prepared: extra }
136
+ args << Event.trigger(:resolve, field, self, **extra, &field.resolver)
136
137
  elsif field.prepared_data?
137
138
  args << prepared_data_for(field)
138
139
  else
@@ -206,11 +207,14 @@ module Rails
206
207
 
207
208
  # Get the prepared data for the given +field+, getting ready for
208
209
  # resolve, while ensuring to check prepared data on request
209
- def prepared_data_for(field)
210
- return @data_pool[field] unless field.prepared_data?
211
-
212
- prepared = request.prepared_data_for(field).next
213
- prepared unless prepared === PreparedData::NULL
210
+ def prepared_data_for(field, with_null: false)
211
+ if field.prepared_data?
212
+ request.prepared_data_for(field).next
213
+ elsif @data_pool.key?(field)
214
+ @data_pool[field]
215
+ elsif with_null
216
+ PreparedData::NULL
217
+ end
214
218
  end
215
219
 
216
220
  # Simply run the organize step for compilation
@@ -256,6 +256,12 @@ module Rails
256
256
  # Once the records are pre-loaded due to +preload_association+, use the
257
257
  # parent value and the preloader result to get the records
258
258
  def parent_owned_records(collection_result = false)
259
+ # The absence of the prepared data key means we got to a point that we
260
+ # don't know the result of the association, so we simply call it
261
+ unless event.data.key?(:prepared_data)
262
+ return current_value.public_send(field.method_name)
263
+ end
264
+
259
265
  data = event.data[:prepared_data]
260
266
  return collection_result ? [] : nil unless data
261
267
 
@@ -14,7 +14,7 @@ module Rails
14
14
  module VERSION
15
15
  MAJOR = 1
16
16
  MINOR = 0
17
- TINY = 5
17
+ TINY = 6
18
18
  PRE = nil
19
19
 
20
20
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
@@ -226,6 +226,10 @@ type LiteShip {
226
226
  name: String
227
227
  }
228
228
 
229
+ type Sample {
230
+ faction: LiteFaction!
231
+ }
232
+
229
233
  type _Mutation {
230
234
  createLiteBase(liteBase: LiteBaseInput!): LiteBase!
231
235
 
@@ -262,6 +266,8 @@ type _Query {
262
266
  liteShip(id: ID!): LiteShip!
263
267
 
264
268
  liteShips: [LiteShip!]!
269
+
270
+ sample: Sample!
265
271
  }
266
272
 
267
273
  """
@@ -95,4 +95,16 @@ class StartWarsSqliteSchema < GraphQL::Schema
95
95
  end
96
96
 
97
97
  source LiteShip
98
+
99
+ object 'Sample' do
100
+ field :faction, 'LiteFaction', null: false
101
+ end
102
+
103
+ query_fields do
104
+ field :sample, 'Sample', null: false
105
+ end
106
+
107
+ def sample
108
+ { faction: LiteFaction.last }
109
+ end
98
110
  end
@@ -88,4 +88,13 @@ class Integration_SQLite_StarWarsQueryTest < GraphQL::IntegrationTestCase
88
88
  query EmpireFleet { liteFaction(id: "2") { greeting } }
89
89
  GQL
90
90
  end
91
+
92
+ def test_nested_non_prepared_source
93
+ bases = named_list('Death Star', 'Shield Generator', 'Headquarters')
94
+ sample = { sample: { faction: { name: 'Galactic Empire', bases: bases } } }
95
+
96
+ assert_result({ data: sample }, <<~GQL)
97
+ query SampleFaction { sample { faction { name bases { name } } } }
98
+ GQL
99
+ end
91
100
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-graphql
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carlos Silva
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-07-30 00:00:00.000000000 Z
11
+ date: 2025-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails