Sha256: 12f5adf829dc083bdaeec94217df552a35fb8e96331399f8050fd0c505ddb42a

Contents?: true

Size: 458 Bytes

Versions: 10

Compression:

Stored size: 458 Bytes

Contents

# frozen_string_literal: true

require_relative './base'
require_relative './node'

module GQLi
  # Fragment wrapper
  class Fragment < Base
    attr_reader :__on_type

    def initialize(name, on, &block)
      super(name, 0, &block)
      @__on_type = on
    end

    # Serializes to a GraphQL string
    def to_gql
      <<~GQL
        fragment #{__name} on #{__on_type} {
        #{__nodes.map(&:to_gql).join("\n")}
        }
      GQL
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
gqli-1.2.0 lib/gqli/fragment.rb
gqli-1.1.0 lib/gqli/fragment.rb
gqli-1.0.0 lib/gqli/fragment.rb
gqli-0.6.1 lib/gqli/fragment.rb
gqli-0.6.0 lib/gqli/fragment.rb
gqli-0.5.0 lib/gqli/fragment.rb
gqli-0.4.0 lib/gqli/fragment.rb
gqli-0.3.0 lib/gqli/fragment.rb
gqli-0.2.0 lib/gqli/fragment.rb
gqli-0.1.0 lib/gqli/fragment.rb