zf

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

operation.ex (1783B)


      1 defmodule Absinthe.Blueprint.Document.Operation do
      2   @moduledoc false
      3 
      4   alias Absinthe.Blueprint
      5 
      6   @enforce_keys [:name, :type]
      7   defstruct [
      8     :name,
      9     :type,
     10     current: false,
     11     selections: [],
     12     directives: [],
     13     variable_definitions: [],
     14     variable_uses: [],
     15     fragment_uses: [],
     16     source_location: nil,
     17     # Populated by phases
     18     flags: %{},
     19     schema_node: nil,
     20     complexity: nil,
     21     provided_values: %{},
     22     errors: []
     23   ]
     24 
     25   @type t :: %__MODULE__{
     26           name: nil | String.t(),
     27           type: :query | :mutation | :subscription,
     28           current: boolean,
     29           directives: [Blueprint.Directive.t()],
     30           selections: [Blueprint.Document.selection_t()],
     31           variable_definitions: [Blueprint.Document.VariableDefinition.t()],
     32           variable_uses: [Blueprint.Input.Variable.Use.t()],
     33           fragment_uses: [Blueprint.Document.Fragment.Named.Use.t()],
     34           source_location: nil | Blueprint.SourceLocation.t(),
     35           schema_node: nil | Absinthe.Type.Object.t(),
     36           complexity: nil | non_neg_integer,
     37           provided_values: %{String.t() => nil | Blueprint.Input.t()},
     38           flags: Blueprint.flags_t(),
     39           errors: [Absinthe.Phase.Error.t()]
     40         }
     41 
     42   @doc """
     43   Determine if a fragment or variable is used by an operation.
     44   """
     45   @spec uses?(t, Blueprint.node_t()) :: boolean
     46   def uses?(op, %Blueprint.Document.Fragment.Named{} = node) do
     47     do_uses?(op.fragment_uses, node)
     48   end
     49 
     50   def uses?(op, %Blueprint.Input.Variable{} = node) do
     51     do_uses?(op.variable_uses, node)
     52   end
     53 
     54   # Whether a node is marked as used in a use list
     55   @spec do_uses?([Blueprint.use_t()], Blueprint.node_t()) :: boolean
     56   defp do_uses?(list, node) do
     57     Enum.find(list, &(&1.name == node.name))
     58   end
     59 end