graph_weaver 0.7.4 → 0.7.5
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 +2 -2
- data/README.md +1 -0
- data/docs/errors.md +5 -2
- data/docs/generated_modules.md +127 -14
- data/docs/getting_started.md +159 -14
- data/docs/migrating.md +119 -0
- data/docs/scalars.md +39 -4
- data/docs/testing.md +3 -1
- data/docs/upgrading.md +21 -1
- data/lib/generators/graph_weaver/install_generator.rb +32 -3
- data/lib/graph_weaver/codegen/aliases.rb +23 -2
- data/lib/graph_weaver/codegen/emit.rb +13 -9
- data/lib/graph_weaver/codegen/enum_type.rb +26 -9
- data/lib/graph_weaver/codegen/nodes.rb +55 -31
- data/lib/graph_weaver/codegen.rb +198 -90
- data/lib/graph_weaver/coerce.rb +1 -1
- data/lib/graph_weaver/federation.rb +1 -6
- data/lib/graph_weaver/hints.rb +20 -5
- data/lib/graph_weaver/in_process.rb +1 -3
- data/lib/graph_weaver/input_struct.rb +21 -6
- data/lib/graph_weaver/internal/subgraphs.rb +1 -10
- data/lib/graph_weaver/internal/unused.rb +32 -7
- data/lib/graph_weaver/internal/values.rb +7 -2
- data/lib/graph_weaver/internal.rb +17 -0
- data/lib/graph_weaver/logging.rb +26 -29
- data/lib/graph_weaver/query_module.rb +20 -5
- data/lib/graph_weaver/railtie.rb +7 -2
- data/lib/graph_weaver/rspec.rb +0 -1
- data/lib/graph_weaver/schema_loader.rb +7 -8
- data/lib/graph_weaver/tasks.rb +60 -5
- data/lib/graph_weaver/testing/fake_client.rb +4 -10
- data/lib/graph_weaver/testing/router.rb +26 -25
- data/lib/graph_weaver/testing.rb +1 -2
- data/lib/graph_weaver/version.rb +1 -1
- data/lib/graph_weaver.rb +13 -7
- metadata +3 -2
data/lib/graph_weaver.rb
CHANGED
|
@@ -214,7 +214,7 @@ module GraphWeaver
|
|
|
214
214
|
attr_accessor :skip_generated_load
|
|
215
215
|
|
|
216
216
|
# The name of the shared module — the types that live once per schema
|
|
217
|
-
# (input types, enums,
|
|
217
|
+
# (input types, enums, the types hoisted from shared fragments) and are
|
|
218
218
|
# aliased into every query module that touches them. Constant, not derived
|
|
219
219
|
# from where you put the files: set it globally, or pass types_module: per
|
|
220
220
|
# generate!. A multi-schema layout names it in the same initializer that
|
|
@@ -795,7 +795,7 @@ module GraphWeaver
|
|
|
795
795
|
|
|
796
796
|
# (filename, source) per artifact. Types a schema shares across queries —
|
|
797
797
|
# input types, schema enums, and each named shared fragment spread as a
|
|
798
|
-
# whole
|
|
798
|
+
# whole field — are emitted once into the shared module, with query
|
|
799
799
|
# modules aliasing what they use. That's the difference between hundreds of
|
|
800
800
|
# duplicated bool_exp structs (or one Ruby class per query for the same
|
|
801
801
|
# schema enum) and one copy per schema. (Single-query parse inlines
|
|
@@ -814,7 +814,7 @@ module GraphWeaver
|
|
|
814
814
|
@unmatched_registrations |= registry.unmatched_registrations(schema)
|
|
815
815
|
|
|
816
816
|
used = { inputs: [], enums: [], mapped: [] }
|
|
817
|
-
|
|
817
|
+
hoisted = []
|
|
818
818
|
helpers = []
|
|
819
819
|
shared = Codegen.load_fragments(fragments)
|
|
820
820
|
|
|
@@ -831,14 +831,14 @@ module GraphWeaver
|
|
|
831
831
|
name:,
|
|
832
832
|
graph_name: graph.name,
|
|
833
833
|
types_namespace: graph.types_module,
|
|
834
|
-
|
|
834
|
+
hoistable_fragments: Codegen.shared_fragment_spreads(source, shared, path),
|
|
835
835
|
path:,
|
|
836
836
|
registry:,
|
|
837
837
|
)
|
|
838
838
|
out = codegen.generate
|
|
839
839
|
codegen.variable_type_names.each { |kind, names| used[kind] |= names }
|
|
840
840
|
found.concat(codegen.untyped_scalars).uniq!
|
|
841
|
-
|
|
841
|
+
hoisted |= codegen.used_fragment_names
|
|
842
842
|
helpers |= codegen.block_helpers
|
|
843
843
|
[filename, out]
|
|
844
844
|
rescue GraphWeaver::Error => e
|
|
@@ -849,12 +849,12 @@ module GraphWeaver
|
|
|
849
849
|
end
|
|
850
850
|
refuse_all!(refusals, paths.size)
|
|
851
851
|
|
|
852
|
-
if
|
|
852
|
+
if hoisted.any? || used.values.any?(&:any?)
|
|
853
853
|
refuse_duplicate_types!(seen, graph)
|
|
854
854
|
codegen = Codegen.new(schema:, query: "", name: graph.types_module, registry:)
|
|
855
855
|
types = codegen.generate_types(
|
|
856
856
|
inputs: used[:inputs], enums: used[:enums] + used[:mapped],
|
|
857
|
-
|
|
857
|
+
hoisted:, fragments: shared,
|
|
858
858
|
)
|
|
859
859
|
found.concat(codegen.untyped_scalars).uniq!
|
|
860
860
|
helpers |= codegen.block_helpers
|
|
@@ -1051,6 +1051,12 @@ module GraphWeaver
|
|
|
1051
1051
|
# mid-rename needs:
|
|
1052
1052
|
#
|
|
1053
1053
|
# GraphWeaver.register_enum("Status", alias: { "legacy_mode" => "LEGACY_MODE" })
|
|
1054
|
+
#
|
|
1055
|
+
# fallback: true is the type-less form of forward-compat: the generated
|
|
1056
|
+
# enum gains an Other member and casts every value the schema doesn't
|
|
1057
|
+
# declare to it, so a server adding one doesn't take the client down.
|
|
1058
|
+
#
|
|
1059
|
+
# GraphWeaver.register_enum("Species", fallback: true)
|
|
1054
1060
|
def register_enum(graphql_name, type = nil, positional_map = nil, map: nil, fallback: nil, requires: nil,
|
|
1055
1061
|
alias: nil)
|
|
1056
1062
|
# `alias` is a Ruby keyword, so the parameter is only readable through binding
|
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.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Daniel Pepper
|
|
@@ -281,6 +281,7 @@ files:
|
|
|
281
281
|
- docs/getting_started.md
|
|
282
282
|
- docs/i18n.md
|
|
283
283
|
- docs/logging.md
|
|
284
|
+
- docs/migrating.md
|
|
284
285
|
- docs/real_world.md
|
|
285
286
|
- docs/scalars.md
|
|
286
287
|
- docs/testing.md
|
|
@@ -363,7 +364,7 @@ licenses:
|
|
|
363
364
|
- MIT
|
|
364
365
|
metadata:
|
|
365
366
|
bug_tracker_uri: https://github.com/dpep/graph_weaver/issues
|
|
366
|
-
changelog_uri: https://github.com/dpep/graph_weaver/blob/v0.7.
|
|
367
|
+
changelog_uri: https://github.com/dpep/graph_weaver/blob/v0.7.5/CHANGELOG.md
|
|
367
368
|
documentation_uri: https://github.com/dpep/graph_weaver/tree/main/docs
|
|
368
369
|
rubygems_mfa_required: 'true'
|
|
369
370
|
source_code_uri: https://github.com/dpep/graph_weaver
|