graph_weaver 0.7.1 → 0.7.3
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/Gemfile.lock +19 -19
- data/docs/federation.md +8 -8
- data/docs/generated_modules.md +28 -21
- data/docs/getting_started.md +14 -13
- data/docs/testing.md +17 -14
- data/docs/transports.md +16 -9
- data/docs/upgrading.md +28 -5
- data/examples/github/generated/star_mutation.rb +4 -4
- data/examples/github/generated/stargazers_query.rb +4 -4
- data/examples/github/generated/starred_query.rb +4 -4
- data/lib/graph_weaver/client.rb +8 -0
- data/lib/graph_weaver/codegen/emit.rb +5 -11
- data/lib/graph_weaver/codegen.rb +18 -54
- data/lib/graph_weaver/graph.rb +39 -29
- data/lib/graph_weaver/internal/test_clients.rb +7 -11
- data/lib/graph_weaver/internal.rb +15 -0
- data/lib/graph_weaver/query_module.rb +36 -23
- data/lib/graph_weaver/railtie.rb +202 -147
- data/lib/graph_weaver/rspec.rb +13 -24
- data/lib/graph_weaver/tasks.rb +10 -2
- data/lib/graph_weaver/testing.rb +12 -4
- data/lib/graph_weaver/version.rb +1 -1
- data/lib/graph_weaver.rb +26 -9
- metadata +2 -2
data/lib/graph_weaver.rb
CHANGED
|
@@ -65,8 +65,8 @@ module GraphWeaver
|
|
|
65
65
|
#
|
|
66
66
|
# Anything satisfying the execute contract — a Client, a schema class,
|
|
67
67
|
# a transport, a fake (testing's graphql: tag swaps one in per
|
|
68
|
-
# example). Generated modules resolve per call ->
|
|
69
|
-
#
|
|
68
|
+
# example). Generated modules resolve per call -> a test mode's stand-in
|
|
69
|
+
# -> the client their graph names -> here.
|
|
70
70
|
attr_accessor :client
|
|
71
71
|
|
|
72
72
|
# the default client, when one is required
|
|
@@ -195,6 +195,7 @@ module GraphWeaver
|
|
|
195
195
|
|
|
196
196
|
def generated_paths=(paths)
|
|
197
197
|
@generated_paths = paths && Array(paths)
|
|
198
|
+
hide_from_autoloading(generated_paths)
|
|
198
199
|
end
|
|
199
200
|
|
|
200
201
|
def fragments_paths=(paths)
|
|
@@ -287,9 +288,24 @@ module GraphWeaver
|
|
|
287
288
|
# generate! reports in however many times the initializer has re-run
|
|
288
289
|
existing = @graphs.index { |candidate| candidate.name == name }
|
|
289
290
|
existing ? @graphs[existing] = graph : @graphs << graph
|
|
291
|
+
hide_from_autoloading([graph.output])
|
|
290
292
|
graph
|
|
291
293
|
end
|
|
292
294
|
|
|
295
|
+
# Rails only: where a graph writes is hidden from Zeitwerk the moment the
|
|
296
|
+
# graph says it. Knowing it any later needed an initializer edge waiting on
|
|
297
|
+
# config/initializers, and such an edge reorders the whole app's boot (see
|
|
298
|
+
# the Railtie). Registered first, so a refusal can name the graph.
|
|
299
|
+
def hide_from_autoloading(paths)
|
|
300
|
+
# by name, not spelled: the railtie is Rails-only and `typed: ignore`, so
|
|
301
|
+
# sorbet has no constant to resolve
|
|
302
|
+
return unless const_defined?(:Railtie, false)
|
|
303
|
+
|
|
304
|
+
railtie = const_get(:Railtie, false)
|
|
305
|
+
paths.each { |path| railtie.ignore_output!(path) }
|
|
306
|
+
end
|
|
307
|
+
private :hide_from_autoloading
|
|
308
|
+
|
|
293
309
|
# Every graph an entry point walks: the declared ones, or the single graph
|
|
294
310
|
# the top-level settings describe. Never empty.
|
|
295
311
|
def graphs = @graphs&.dup || [default_graph]
|
|
@@ -389,7 +405,7 @@ module GraphWeaver
|
|
|
389
405
|
# (see #changed_files). Generated files the plan no longer produces are deleted
|
|
390
406
|
# (see #orphaned), so renaming or dropping a .graphql leaves nothing
|
|
391
407
|
# behind. Pair with a freshness spec (docs/generated_modules.md).
|
|
392
|
-
def generate!(schema: nil, queries: nil, output: nil,
|
|
408
|
+
def generate!(schema: nil, queries: nil, output: nil, types_module: nil)
|
|
393
409
|
@changed_files = []
|
|
394
410
|
@unmatched_registrations = []
|
|
395
411
|
@untyped_scalars_by_graph = {}
|
|
@@ -399,7 +415,7 @@ module GraphWeaver
|
|
|
399
415
|
# tree exactly as it was — the railtie's watch mode regenerates on a
|
|
400
416
|
# request and promises a failed save changes nothing, and that promise
|
|
401
417
|
# was true within a graph and false across them.
|
|
402
|
-
planned = graphs_for(schema:, queries:, output:,
|
|
418
|
+
planned = graphs_for(schema:, queries:, output:, types_module:).map do |graph|
|
|
403
419
|
if Internal::Util.query_files(graph.queries).empty?
|
|
404
420
|
# a brand-new app legitimately has none; a mistyped queries_paths looks
|
|
405
421
|
# exactly the same, and prints nothing either way
|
|
@@ -488,11 +504,11 @@ module GraphWeaver
|
|
|
488
504
|
# it "generated queries are current" do
|
|
489
505
|
# GraphWeaver.verify_generated!
|
|
490
506
|
# end
|
|
491
|
-
def verify_generated!(schema: nil, queries: nil, output: nil,
|
|
507
|
+
def verify_generated!(schema: nil, queries: nil, output: nil, types_module: nil)
|
|
492
508
|
@unmatched_registrations = []
|
|
493
509
|
@untyped_scalars_by_graph = {}
|
|
494
510
|
seen = new_seen
|
|
495
|
-
graphs = graphs_for(schema:, queries:, output:,
|
|
511
|
+
graphs = graphs_for(schema:, queries:, output:, types_module:)
|
|
496
512
|
|
|
497
513
|
# The dump is checked in too, and everything below reads it — so a
|
|
498
514
|
# stale one is answered before staleness downstream of it, because
|
|
@@ -860,7 +876,6 @@ module GraphWeaver
|
|
|
860
876
|
schema:,
|
|
861
877
|
query: Codegen.inline_fragments(source, shared, path),
|
|
862
878
|
name:,
|
|
863
|
-
client: graph.client,
|
|
864
879
|
graph_name: graph.name,
|
|
865
880
|
types_namespace: graph.types_module,
|
|
866
881
|
hoistable_unions: Codegen.shared_fragment_spreads(source, shared, path),
|
|
@@ -1082,8 +1097,10 @@ module GraphWeaver
|
|
|
1082
1097
|
# name derived from the file name and the operation — see #module_name) or
|
|
1083
1098
|
# a raw query string (name derived from the operation name, falling back to
|
|
1084
1099
|
# "Query" for anonymous operations — collisions are impossible since each
|
|
1085
|
-
# parse gets its own container). Pass name: to override, client: to
|
|
1086
|
-
# the module
|
|
1100
|
+
# parse gets its own container). Pass name: to override, client: to say
|
|
1101
|
+
# what the module runs against — a parsed module generates no file, so it
|
|
1102
|
+
# has no graph to read one off, and this is the only time one is bound
|
|
1103
|
+
# (a per-call `client:` still wins).
|
|
1087
1104
|
#
|
|
1088
1105
|
# graph: names the graph this module belongs to, which is what a test mode
|
|
1089
1106
|
# runs it against in an app with more than one — the same thing generation
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: graph_weaver
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.7.
|
|
4
|
+
version: 0.7.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Daniel Pepper
|
|
@@ -363,7 +363,7 @@ licenses:
|
|
|
363
363
|
- MIT
|
|
364
364
|
metadata:
|
|
365
365
|
bug_tracker_uri: https://github.com/dpep/graph_weaver/issues
|
|
366
|
-
changelog_uri: https://github.com/dpep/graph_weaver/blob/v0.7.
|
|
366
|
+
changelog_uri: https://github.com/dpep/graph_weaver/blob/v0.7.3/CHANGELOG.md
|
|
367
367
|
documentation_uri: https://github.com/dpep/graph_weaver/tree/main/docs
|
|
368
368
|
rubygems_mfa_required: 'true'
|
|
369
369
|
source_code_uri: https://github.com/dpep/graph_weaver
|