apollo-federation 3.6.5 → 3.6.7
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 +14 -0
- data/README.md +3 -1
- data/lib/apollo-federation/entities_field.rb +16 -4
- data/lib/apollo-federation/tracing.rb +2 -1
- data/lib/apollo-federation/version.rb +1 -1
- 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: 37bac5e46b177feadaa9327163e07d68e25789f9bccf0ba6cb112204cab77ccc
         | 
| 4 | 
            +
              data.tar.gz: 19a02cf54f5fe7648f77631c564190951944cd68a4a8687e50ee1001559286f9
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: fe67ad551e2af8730ed54f7eda506f3d6d3af0b66ca7f1ec3de48a9ddb5c6809b7483b5144511cd62f4ee1c2e788a3e360c1a2d58bf83e38f1e613a581b341ec
         | 
| 7 | 
            +
              data.tar.gz: f73c5f3551333026d1ede990f2800a0e406d5b21f23b59d91f06ddc1227ba8ef6ba7db4008f1173a0d46aef8df77c079970c29f3f3446ff49b9eb11f26c4f5ff
         | 
    
        data/CHANGELOG.md
    CHANGED
    
    | @@ -1,3 +1,17 @@ | |
| 1 | 
            +
            ## [3.6.7](https://github.com/Gusto/apollo-federation-ruby/compare/v3.6.6...v3.6.7) (2023-05-18)
         | 
| 2 | 
            +
             | 
| 3 | 
            +
             | 
| 4 | 
            +
            ### Bug Fixes
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            * call `resolve_references` once per `__typename` ([#244](https://github.com/Gusto/apollo-federation-ruby/issues/244)) ([c21715d](https://github.com/Gusto/apollo-federation-ruby/commit/c21715d28b67764a078b4daefdfe490f50171817))
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            ## [3.6.6](https://github.com/Gusto/apollo-federation-ruby/compare/v3.6.5...v3.6.6) (2023-04-26)
         | 
| 9 | 
            +
             | 
| 10 | 
            +
             | 
| 11 | 
            +
            ### Bug Fixes
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            * ApolloFederation::Tracing.should_add_traces() looks for correct headers ([#240](https://github.com/Gusto/apollo-federation-ruby/issues/240)) ([d609977](https://github.com/Gusto/apollo-federation-ruby/commit/d609977869721c168b33e50e3823cd97a7f81ae5))
         | 
| 14 | 
            +
             | 
| 1 15 | 
             
            ## [3.6.5](https://github.com/Gusto/apollo-federation-ruby/compare/v3.6.4...v3.6.5) (2023-04-25)
         | 
| 2 16 |  | 
| 3 17 |  | 
    
        data/README.md
    CHANGED
    
    | @@ -333,7 +333,9 @@ To support [federated tracing](https://www.apollographql.com/docs/apollo-server/ | |
| 333 333 | 
             
               def execute
         | 
| 334 334 | 
             
                 # ...
         | 
| 335 335 | 
             
                 context = {
         | 
| 336 | 
            -
                    | 
| 336 | 
            +
                   # Pass in the headers from your web framework. For Rails this will be request.headers
         | 
| 337 | 
            +
                   # but for other frameworks you can pass the Rack env.
         | 
| 338 | 
            +
                   tracing_enabled: ApolloFederation::Tracing.should_add_traces(request.headers)
         | 
| 337 339 | 
             
                 }
         | 
| 338 340 | 
             
                 # ...
         | 
| 339 341 | 
             
               end
         | 
| @@ -27,9 +27,17 @@ module ApolloFederation | |
| 27 27 | 
             
                end
         | 
| 28 28 |  | 
| 29 29 | 
             
                def _entities(representations:)
         | 
| 30 | 
            -
                   | 
| 30 | 
            +
                  final_result = Array.new(representations.size)
         | 
| 31 | 
            +
                  grouped_references_with_indices =
         | 
| 32 | 
            +
                    representations
         | 
| 33 | 
            +
                    .map
         | 
| 34 | 
            +
                    .with_index { |r, i| [r, i] }
         | 
| 35 | 
            +
                    .group_by { |(r, _i)| r[:__typename] }
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                  grouped_references_with_indices.each do |typename, references_with_indices|
         | 
| 38 | 
            +
                    references = references_with_indices.map(&:first)
         | 
| 39 | 
            +
                    indices = references_with_indices.map(&:last)
         | 
| 31 40 |  | 
| 32 | 
            -
                  chunked_references.flat_map do |typename, references|
         | 
| 33 41 | 
             
                    # TODO: Use warden or schema?
         | 
| 34 42 | 
             
                    type = context.warden.get_type(typename)
         | 
| 35 43 | 
             
                    if type.nil? || type.kind != GraphQL::TypeKinds::OBJECT
         | 
| @@ -49,8 +57,10 @@ module ApolloFederation | |
| 49 57 | 
             
                      results = references
         | 
| 50 58 | 
             
                    end
         | 
| 51 59 |  | 
| 52 | 
            -
                    results. | 
| 53 | 
            -
             | 
| 60 | 
            +
                    results_with_indices = results.zip(indices)
         | 
| 61 | 
            +
             | 
| 62 | 
            +
                    results_with_indices.each do |result, i|
         | 
| 63 | 
            +
                      final_result[i] = context.schema.after_lazy(result) do |resolved_value|
         | 
| 54 64 | 
             
                        # TODO: This isn't 100% correct: if (for some reason) 2 different resolve_reference
         | 
| 55 65 | 
             
                        # calls return the same object, it might not have the right type
         | 
| 56 66 | 
             
                        # Right now, apollo-federation just adds a __typename property to the result,
         | 
| @@ -60,6 +70,8 @@ module ApolloFederation | |
| 60 70 | 
             
                      end
         | 
| 61 71 | 
             
                    end
         | 
| 62 72 | 
             
                  end
         | 
| 73 | 
            +
             | 
| 74 | 
            +
                  final_result
         | 
| 63 75 | 
             
                end
         | 
| 64 76 |  | 
| 65 77 | 
             
                private
         | 
| @@ -2,6 +2,7 @@ | |
| 2 2 |  | 
| 3 3 | 
             
            module ApolloFederation
         | 
| 4 4 | 
             
              module Tracing
         | 
| 5 | 
            +
                HEADER_NAME = 'HTTP_APOLLO_FEDERATION_INCLUDE_TRACE'
         | 
| 5 6 | 
             
                KEY = :ftv1
         | 
| 6 7 | 
             
                DEBUG_KEY = "#{KEY}_debug".to_sym
         | 
| 7 8 |  | 
| @@ -12,7 +13,7 @@ module ApolloFederation | |
| 12 13 | 
             
                end
         | 
| 13 14 |  | 
| 14 15 | 
             
                def should_add_traces(headers)
         | 
| 15 | 
            -
                  headers && headers[ | 
| 16 | 
            +
                  headers && headers[HEADER_NAME] == KEY.to_s
         | 
| 16 17 | 
             
                end
         | 
| 17 18 |  | 
| 18 19 | 
             
                # @deprecated There is no need to call this method. Traces are added to the result automatically
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: apollo-federation
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 3.6. | 
| 4 | 
            +
              version: 3.6.7
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Noa Elad
         | 
| @@ -9,7 +9,7 @@ authors: | |
| 9 9 | 
             
            autorequire: 
         | 
| 10 10 | 
             
            bindir: bin
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 | 
            -
            date: 2023- | 
| 12 | 
            +
            date: 2023-05-18 00:00:00.000000000 Z
         | 
| 13 13 | 
             
            dependencies:
         | 
| 14 14 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 15 | 
             
              name: graphql
         |