Sha256: 38432341c29408895b2e59f8de55cd4d95f82be2a7962166c978aebad5a23c76

Contents?: true

Size: 423 Bytes

Versions: 2

Compression:

Stored size: 423 Bytes

Contents

GraphQL::Directive::IncludeDirective = GraphQL::Directive.new do |d, type, field, arg|
  d.name "include"
  d.description "Include this part of the query if `if` is true"
  d.on([GraphQL::Directive::ON_FIELD, GraphQL::Directive::ON_FRAGMENT])
  d.arguments({
    if: arg.build({type: !GraphQL::BOOLEAN_TYPE})
  })
  d.resolve -> (arguments, proc) {
    if arguments["if"]
      proc.call
    else
      nil
    end
  }
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
graphql-0.5.0 lib/graph_ql/directive/include_directive.rb
graphql-0.4.0 lib/graph_ql/directive/include_directive.rb