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.
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, unions hoisted from shared fragments) and are
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-union field — are emitted once into the shared module, with query
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
- used_unions = []
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
- hoistable_unions: Codegen.shared_fragment_spreads(source, shared, path),
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
- used_unions |= codegen.used_union_names
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 used_unions.any? || used.values.any?(&:any?)
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
- unions: used_unions, fragments: shared,
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
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.4/CHANGELOG.md
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