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 +4 -4
- data/lib/gql_parser.so +0 -0
- data/lib/rails/graphql/request/strategy.rb +11 -7
- data/lib/rails/graphql/source/active_record_source.rb +6 -0
- data/lib/rails/graphql/version.rb +1 -1
- data/test/assets/sqlite.gql +6 -0
- data/test/integration/schemas/sqlite.rb +12 -0
- data/test/integration/sqlite/star_wars_query_test.rb +9 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d18315ad503f122d67555202db0417507d7b5d72ecf5c060396bf7974b7cf826
|
4
|
+
data.tar.gz: 3688696c6d83cd9aebe2be3024906292bbdd291f3fb4b272bb5b1841714ba10e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
135
|
-
|
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
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
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
|
|
data/test/assets/sqlite.gql
CHANGED
@@ -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.
|
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-
|
11
|
+
date: 2025-08-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|