Sha256: 59aa5bd8cd54fad0b3cf3b63dfac1b5729ff01ab15453a6e77a13eca1697eb19

Contents?: true

Size: 647 Bytes

Versions: 5

Compression:

Stored size: 647 Bytes

Contents

# frozen_string_literal: true

module Rails
  module GraphQL
    # = GraphQL Spec Include Directive
    #
    # Allow including fields only +if+ condition is true
    class Directive::IncludeDirective < Directive
      self.spec_object = true

      placed_on :field, :fragment_spread, :inline_fragment

      desc 'Allows for conditional inclusion during execution as described by the if argument.'

      argument :if, :boolean, null: false, desc: <<~DESC
        When false, the underlying element will be automatically marked as null.
      DESC

      on(:attach) do |source|
        source.skip! unless args[:if]
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rails-graphql-1.0.2 lib/rails/graphql/directive/include_directive.rb
rails-graphql-1.0.1 lib/rails/graphql/directive/include_directive.rb
rails-graphql-1.0.0 lib/rails/graphql/directive/include_directive.rb
rails-graphql-1.0.0.rc2 lib/rails/graphql/directive/include_directive.rb
rails-graphql-1.0.0.rc1 lib/rails/graphql/directive/include_directive.rb