Sha256: f2aec16453e13ae903c6e2f130053f0e44ca0002f3789374d87a15c7e06da675

Contents?: true

Size: 658 Bytes

Versions: 15

Compression:

Stored size: 658 Bytes

Contents

# frozen_string_literal: true

module WCC::Contentful::Graphql::Federation
  BuildsArguments =
    Struct.new(:argument) do
      def self.call(arguments)
        arguments.map { |arg| new(arg).call }
      end

      def call
        return argument if argument.is_a? GraphQL::Language::Nodes::Argument

        GraphQL::Language::Nodes::Argument.new(name: key, value: value)
      end

      private

      def key
        argument[0]
      end

      def value
        if argument[1].is_a? Hash
          return GraphQL::Language::Nodes::InputObject.new(arguments: BuildsArguments.call(argument[1]))
        end

        argument[1]
      end
    end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
wcc-contentful-graphql-1.2.0 lib/wcc/contentful/graphql/federation/builds_arguments.rb
wcc-contentful-graphql-1.1.2 lib/wcc/contentful/graphql/federation/builds_arguments.rb
wcc-contentful-graphql-1.1.1 lib/wcc/contentful/graphql/federation/builds_arguments.rb
wcc-contentful-graphql-1.1.0 lib/wcc/contentful/graphql/federation/builds_arguments.rb
wcc-contentful-graphql-1.0.8 lib/wcc/contentful/graphql/federation/builds_arguments.rb
wcc-contentful-graphql-1.0.7 lib/wcc/contentful/graphql/federation/builds_arguments.rb
wcc-contentful-graphql-1.0.6 lib/wcc/contentful/graphql/federation/builds_arguments.rb
wcc-contentful-graphql-1.0.5 lib/wcc/contentful/graphql/federation/builds_arguments.rb
wcc-contentful-graphql-1.0.4 lib/wcc/contentful/graphql/federation/builds_arguments.rb
wcc-contentful-graphql-1.0.3 lib/wcc/contentful/graphql/federation/builds_arguments.rb
wcc-contentful-graphql-1.0.1 lib/wcc/contentful/graphql/federation/builds_arguments.rb
wcc-contentful-graphql-1.0.0 lib/wcc/contentful/graphql/federation/builds_arguments.rb
wcc-contentful-graphql-1.0.0.pre.rc3 lib/wcc/contentful/graphql/federation/builds_arguments.rb
wcc-contentful-graphql-1.0.0.pre.rc2 lib/wcc/contentful/graphql/federation/builds_arguments.rb
wcc-contentful-graphql-1.0.0.pre.rc1 lib/wcc/contentful/graphql/federation/builds_arguments.rb