Sha256: 6b26b3e2c1c185c519eefd8ca3cb08c8256be708740812f507ac6ef1e3da3872

Contents?: true

Size: 412 Bytes

Versions: 2

Compression:

Stored size: 412 Bytes

Contents

GraphQL::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.3.0 lib/graph_ql/directives/include_directive.rb
graphql-0.2.0 lib/graph_ql/directives/include_directive.rb