zf

zenflows testing
git clone https://s.sonu.ch/~srfsh/zf.git
Log | Files | Refs | Submodules | README | LICENSE

directives.ex (1065B)


      1 defmodule Absinthe.Type.BuiltIns.Directives do
      2   @moduledoc false
      3   use Absinthe.Schema.Notation
      4 
      5   alias Absinthe.Blueprint
      6 
      7   directive :include do
      8     description """
      9     Directs the executor to include this field or fragment only when the `if` argument is true.
     10     """
     11 
     12     arg :if, non_null(:boolean), description: "Included when true."
     13 
     14     on [:field, :fragment_spread, :inline_fragment]
     15 
     16     repeatable false
     17 
     18     expand fn
     19       %{if: true}, node ->
     20         Blueprint.put_flag(node, :include, __MODULE__)
     21 
     22       _, node ->
     23         Blueprint.put_flag(node, :skip, __MODULE__)
     24     end
     25   end
     26 
     27   directive :skip do
     28     description """
     29     Directs the executor to skip this field or fragment when the `if` argument is true.
     30     """
     31 
     32     repeatable false
     33 
     34     arg :if, non_null(:boolean), description: "Skipped when true."
     35 
     36     on [:field, :fragment_spread, :inline_fragment]
     37 
     38     expand fn
     39       %{if: true}, node ->
     40         Blueprint.put_flag(node, :skip, __MODULE__)
     41 
     42       _, node ->
     43         Blueprint.put_flag(node, :include, __MODULE__)
     44     end
     45   end
     46 end