graph_weaver 0.2.1 → 0.2.2
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/CHANGELOG.md +6 -0
- data/Gemfile.lock +21 -30
- data/docs/generated_modules.md +35 -0
- data/lib/graph_weaver/codegen/emit.rb +28 -4
- data/lib/graph_weaver/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7673fd6efc0459bdb3097e73e1c3f8fe265910bfdaf349bf7a358adc1ece1830
|
|
4
|
+
data.tar.gz: f5ce9f4c484e1fb8f5eb074eaaac502ca62fb3ecf6ab90d9157a2a055e88c3b3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a75dd5a723dd52108e2f449bd1c5f0e1dc9a71065106614c57854f318024f700e16596cd4764cf9768f02d536cc040bd0554bdd75762eeba23c09b71a7051cf5
|
|
7
|
+
data.tar.gz: 377c07a20d2cf47873425c72ad84709c36555396fea1a2102c7bdc3f79e07e8e823ed9639238aecac8066f352e65599a10ae15a71013a7de3a0a4d3675bf169c
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
### v0.2.2 (2026-07-22)
|
|
2
|
+
- Generated modules expose from_response / from_response! alongside
|
|
3
|
+
execute / execute!: deserialize a raw GraphQL response (fetched by any
|
|
4
|
+
client) into the typed envelope without going through the transport.
|
|
5
|
+
execute now delegates to from_response
|
|
6
|
+
|
|
1
7
|
### v0.2.1 (2026-07-13)
|
|
2
8
|
- Conventional paths are appendable lists: queries_paths /
|
|
3
9
|
generated_paths (singular accessors read the first entry, so existing
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
graph_weaver (0.2.
|
|
4
|
+
graph_weaver (0.2.2)
|
|
5
5
|
graphql (>= 2)
|
|
6
6
|
sorbet-runtime
|
|
7
7
|
|
|
@@ -19,7 +19,6 @@ GEM
|
|
|
19
19
|
irb (~> 1.10)
|
|
20
20
|
reline (>= 0.3.8)
|
|
21
21
|
diff-lcs (1.6.2)
|
|
22
|
-
docile (1.4.1)
|
|
23
22
|
erb (6.0.4)
|
|
24
23
|
erubi (1.13.1)
|
|
25
24
|
faker (3.8.0)
|
|
@@ -43,7 +42,7 @@ GEM
|
|
|
43
42
|
google-protobuf (4.35.1-x86_64-linux-gnu)
|
|
44
43
|
bigdecimal
|
|
45
44
|
rake (~> 13.3)
|
|
46
|
-
graphql (2.6.
|
|
45
|
+
graphql (2.6.6)
|
|
47
46
|
base64
|
|
48
47
|
fiber-storage
|
|
49
48
|
logger
|
|
@@ -100,21 +99,16 @@ GEM
|
|
|
100
99
|
rubydex (0.2.7-arm64-darwin)
|
|
101
100
|
rubydex (0.2.7-x86_64-darwin)
|
|
102
101
|
rubydex (0.2.7-x86_64-linux)
|
|
103
|
-
simplecov (0.
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
sorbet (0.6.
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
sorbet-static (0.6.13327-universal-darwin)
|
|
114
|
-
sorbet-static (0.6.13327-x86_64-linux)
|
|
115
|
-
sorbet-static-and-runtime (0.6.13327)
|
|
116
|
-
sorbet (= 0.6.13327)
|
|
117
|
-
sorbet-runtime (= 0.6.13327)
|
|
102
|
+
simplecov (1.0.2)
|
|
103
|
+
sorbet (0.6.13347)
|
|
104
|
+
sorbet-static (= 0.6.13347)
|
|
105
|
+
sorbet-runtime (0.6.13347)
|
|
106
|
+
sorbet-static (0.6.13347-aarch64-linux)
|
|
107
|
+
sorbet-static (0.6.13347-universal-darwin)
|
|
108
|
+
sorbet-static (0.6.13347-x86_64-linux)
|
|
109
|
+
sorbet-static-and-runtime (0.6.13347)
|
|
110
|
+
sorbet (= 0.6.13347)
|
|
111
|
+
sorbet-runtime (= 0.6.13347)
|
|
118
112
|
spoom (1.8.3)
|
|
119
113
|
erubi (>= 1.10.0)
|
|
120
114
|
prism (>= 0.28.0)
|
|
@@ -172,7 +166,6 @@ CHECKSUMS
|
|
|
172
166
|
concurrent-ruby (1.3.7) sha256=4412caec3a5ea2e5fdc52076724c071a81f2c0593d83b2ac8cbb8ca63b3151b0
|
|
173
167
|
debug (1.11.1) sha256=2e0b0ac6119f2207a6f8ac7d4a73ca8eb4e440f64da0a3136c30343146e952b6
|
|
174
168
|
diff-lcs (1.6.2) sha256=9ae0d2cba7d4df3075fe8cd8602a8604993efc0dfa934cff568969efb1909962
|
|
175
|
-
docile (1.4.1) sha256=96159be799bfa73cdb721b840e9802126e4e03dfc26863db73647204c727f21e
|
|
176
169
|
erb (6.0.4) sha256=38e3803694be357fe2bfe312487c74beaf9fb4e5beb3e22498952fe1645b95d9
|
|
177
170
|
erubi (1.13.1) sha256=a082103b0885dbc5ecf1172fede897f9ebdb745a4b97a5e8dc63953db1ee4ad9
|
|
178
171
|
faker (3.8.0) sha256=c147b308df73a90f27a4fc84f18d4c22ef0ad9c2a64b2b61c86fd0ca71753efc
|
|
@@ -183,8 +176,8 @@ CHECKSUMS
|
|
|
183
176
|
google-protobuf (4.35.1-arm64-darwin) sha256=d9c957df04fa89c749fa9a72a7b383eb4296efc9b2303dc6fd6fbe39c698ad6b
|
|
184
177
|
google-protobuf (4.35.1-x86_64-darwin) sha256=66b62b4df00931018a692806df66393efa960d6d2b7da69735187249f950d3ee
|
|
185
178
|
google-protobuf (4.35.1-x86_64-linux-gnu) sha256=c786439087512a3fbd199e9897d265b855f951d4027e218ea55e858d45969edd
|
|
186
|
-
graph_weaver (0.2.
|
|
187
|
-
graphql (2.6.
|
|
179
|
+
graph_weaver (0.2.2)
|
|
180
|
+
graphql (2.6.6) sha256=7438e2036b571c884377eb1529225470ba959365f26dc47152953c213bc38c31
|
|
188
181
|
i18n (1.15.2) sha256=00f9eb62412fe593b2a65a97daa75300d37abb8f7202ec748e94b6d46a9dd1b5
|
|
189
182
|
io-console (0.8.2) sha256=d6e3ae7a7cc7574f4b8893b4fca2162e57a825b223a177b7afa236c5ef9814cc
|
|
190
183
|
irb (1.18.0) sha256=de9454a0703a54704b9811a5ef31a60c86949fbf4013fcf244fabc7c775248e3
|
|
@@ -213,15 +206,13 @@ CHECKSUMS
|
|
|
213
206
|
rubydex (0.2.7-arm64-darwin) sha256=f0d28bbf4153568be79b671642424750053e0bea971b60ddf5cec19bf4563990
|
|
214
207
|
rubydex (0.2.7-x86_64-darwin) sha256=b002b259d118ac69de44470eff1597143318402c45630c47371f9542631447dc
|
|
215
208
|
rubydex (0.2.7-x86_64-linux) sha256=dacfade9fa42ce4469618da6dac07e69d5f3ac6a313b4caced5234c8f052419a
|
|
216
|
-
simplecov (0.
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
sorbet (0.6.
|
|
220
|
-
sorbet-
|
|
221
|
-
sorbet-static (0.6.
|
|
222
|
-
sorbet-static (0.6.
|
|
223
|
-
sorbet-static (0.6.13327-x86_64-linux) sha256=f3a915bab4af1979145c793a08d3b1db207526d5e2f332513da10a95e70f9028
|
|
224
|
-
sorbet-static-and-runtime (0.6.13327) sha256=7b039be023b6a7d2d17b1f751191f32307d9ace4170b6a192bb0e005d222e00e
|
|
209
|
+
simplecov (1.0.2) sha256=c6459434efe4b948b46477cc2df2faa73ab365f83a33c7c17f81262f4f7f1244
|
|
210
|
+
sorbet (0.6.13347) sha256=2830946e6efda8dc732c5d703350bed17f437fbea1ccfbef543a65e33ae445c1
|
|
211
|
+
sorbet-runtime (0.6.13347) sha256=54e7221d9f4b63f58aec79f3043752a9ba7810347c6ae0d903531591cc2d5f01
|
|
212
|
+
sorbet-static (0.6.13347-aarch64-linux) sha256=9bb60509bf9a8715d93e77cd55f96659575d81a5f47b52bd4f66b3dfe6f2182e
|
|
213
|
+
sorbet-static (0.6.13347-universal-darwin) sha256=d12678a45369dba9db724103d8badda995e66a83ae35798f68d804c46a6d3e45
|
|
214
|
+
sorbet-static (0.6.13347-x86_64-linux) sha256=5a4803d2ba4fc1964e23f3aa4073b224c345c2a72a5f5317623a4bae7ce2c8da
|
|
215
|
+
sorbet-static-and-runtime (0.6.13347) sha256=2130e3c20326948a3edd20385b444345cb7327eea9b141f373486e7c087a498d
|
|
225
216
|
spoom (1.8.3) sha256=32871fa189bbfa49cf557a50f819f23cc9a6ceefd0346caa7a6adc193becd5dd
|
|
226
217
|
tapioca (0.19.2) sha256=938731b07811aee8d23871b1aee8861d464fbaf2cfffbf79a62b0c869a5120ec
|
|
227
218
|
thor (1.5.0) sha256=e3a9e55fe857e44859ce104a84675ab6e8cd59c650a49106a05f55f136425e73
|
data/docs/generated_modules.md
CHANGED
|
@@ -119,6 +119,9 @@ module PersonQuery
|
|
|
119
119
|
def self.client ... # default client (see below)
|
|
120
120
|
def self.execute(client = nil, id:) # -> GraphWeaver::Response[Result]
|
|
121
121
|
def self.execute!(client = nil, id:) # -> Result, or raises QueryError
|
|
122
|
+
|
|
123
|
+
def self.from_response(response) # deserialize a raw hash -> Response[Result]
|
|
124
|
+
def self.from_response!(response) # -> Result, or raises QueryError
|
|
122
125
|
end
|
|
123
126
|
```
|
|
124
127
|
|
|
@@ -127,6 +130,38 @@ end
|
|
|
127
130
|
cost/throttle metadata survive.
|
|
128
131
|
- `execute!` is the shortcut: the typed result or a raised
|
|
129
132
|
`GraphWeaver::QueryError`.
|
|
133
|
+
- `from_response` / `from_response!` are the **network-free half** of the
|
|
134
|
+
pair — same envelope, but from a response hash you already have (see below).
|
|
135
|
+
|
|
136
|
+
## Deserializing a response from another client
|
|
137
|
+
|
|
138
|
+
`execute` is two steps: make the request, then cast the JSON into the typed
|
|
139
|
+
structs. Only the second step is GraphWeaver-specific, and it's exposed on its
|
|
140
|
+
own — so you can fetch with any GraphQL client (Apollo, a raw `Net::HTTP` post,
|
|
141
|
+
a batching layer, a recorded fixture) and hand the result to GraphWeaver:
|
|
142
|
+
|
|
143
|
+
```ruby
|
|
144
|
+
raw = my_graphql_client.post(PersonQuery::QUERY, id: "1")
|
|
145
|
+
# => {"data" => {"person" => {...}}, "errors" => [...], "extensions" => {...}}
|
|
146
|
+
|
|
147
|
+
response = PersonQuery.from_response(raw) # GraphWeaver::Response[Result]
|
|
148
|
+
person = response.data!.person # typed, no network
|
|
149
|
+
|
|
150
|
+
# or skip the envelope:
|
|
151
|
+
person = PersonQuery.from_response!(raw).person
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
`from_response` builds the exact same `GraphWeaver::Response[Result]` envelope
|
|
155
|
+
`execute` does — in fact `execute` *is* `from_response(transport.execute(...))`.
|
|
156
|
+
Errors and extensions are preserved; `#data!` / `from_response!` raise
|
|
157
|
+
`QueryError` on top-level errors.
|
|
158
|
+
|
|
159
|
+
The one requirement: pass the response **verbatim** — a hash (or anything with
|
|
160
|
+
`#to_h`) with the standard GraphQL shape and **wire-cased string keys**
|
|
161
|
+
(`"person"`, `"nameWithOwner"`), the top-level `"data"` / `"errors"` /
|
|
162
|
+
`"extensions"` keys included. Don't symbolize or snake_case it first;
|
|
163
|
+
`from_response` reads `raw["data"]` and the casting reads camelCase field keys.
|
|
164
|
+
The module must, of course, be generated for the query you ran.
|
|
130
165
|
|
|
131
166
|
## Variables become typed kwargs
|
|
132
167
|
|
|
@@ -409,7 +409,30 @@ class GraphWeaver::Codegen
|
|
|
409
409
|
|
|
410
410
|
out << ""
|
|
411
411
|
out << " transport = GraphWeaver.resolve_transport(client || self.client)"
|
|
412
|
-
out << "
|
|
412
|
+
out << " from_response(transport.execute(QUERY, variables: variables))"
|
|
413
|
+
out << " end"
|
|
414
|
+
out << ""
|
|
415
|
+
out << " sig { params(#{sig_params.join(", ")}).returns(Result) }"
|
|
416
|
+
out << " def self.execute!(#{kwargs.join(", ")})"
|
|
417
|
+
out << " execute(#{forward}).data!"
|
|
418
|
+
out << " end"
|
|
419
|
+
out << ""
|
|
420
|
+
emit_from_response(out)
|
|
421
|
+
end
|
|
422
|
+
|
|
423
|
+
# The network-free half of execute: deserialize a raw GraphQL response
|
|
424
|
+
# into the typed envelope. For responses fetched by any other client —
|
|
425
|
+
# execute delegates here after the transport call. Accepts the response
|
|
426
|
+
# hash (or anything with #to_h, e.g. a schema result): {"data" => ...,
|
|
427
|
+
# "errors" => ..., "extensions" => ...} with wire-cased string keys.
|
|
428
|
+
def emit_from_response(out)
|
|
429
|
+
out << " # Deserialize a raw GraphQL response into the typed envelope — the"
|
|
430
|
+
out << " # network-free half of execute, for responses fetched by any client."
|
|
431
|
+
out << " # Takes the response hash (or anything with #to_h): {\"data\" => ...,"
|
|
432
|
+
out << " # \"errors\" => ..., \"extensions\" => ...} with wire-cased string keys."
|
|
433
|
+
out << " sig { params(response: T.untyped).returns(GraphWeaver::Response[Result]) }"
|
|
434
|
+
out << " def self.from_response(response)"
|
|
435
|
+
out << " raw = response.to_h"
|
|
413
436
|
out << " GraphWeaver::Response[Result].new("
|
|
414
437
|
out << " data: (Result.from_h(raw[\"data\"]) if raw[\"data\"]),"
|
|
415
438
|
out << " errors: (raw[\"errors\"] || []).map { |e| GraphWeaver::GraphQLError.from_h(e) },"
|
|
@@ -417,9 +440,10 @@ class GraphWeaver::Codegen
|
|
|
417
440
|
out << " )"
|
|
418
441
|
out << " end"
|
|
419
442
|
out << ""
|
|
420
|
-
out << "
|
|
421
|
-
out << "
|
|
422
|
-
out << "
|
|
443
|
+
out << " # from_response + data! — the typed result, or a raised QueryError."
|
|
444
|
+
out << " sig { params(response: T.untyped).returns(Result) }"
|
|
445
|
+
out << " def self.from_response!(response)"
|
|
446
|
+
out << " from_response(response).data!"
|
|
423
447
|
out << " end"
|
|
424
448
|
end
|
|
425
449
|
|
data/lib/graph_weaver/version.rb
CHANGED