zf

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

type.ex (5345B)


      1 # Zenflows is designed to implement the Valueflows vocabulary,
      2 # written and maintained by srfsh <info@dyne.org>.
      3 # Copyright (C) 2021-2023 Dyne.org foundation <foundation@dyne.org>.
      4 #
      5 # This program is free software: you can redistribute it and/or modify
      6 # it under the terms of the GNU Affero General Public License as published by
      7 # the Free Software Foundation, either version 3 of the License, or
      8 # (at your option) any later version.
      9 #
     10 # This program is distributed in the hope that it will be useful,
     11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
     12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13 # GNU Affero General Public License for more details.
     14 #
     15 # You should have received a copy of the GNU Affero General Public License
     16 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
     17 
     18 defmodule Zenflows.VF.RecipeFlow.Type do
     19 @moduledoc false
     20 
     21 use Absinthe.Schema.Notation
     22 
     23 alias Zenflows.VF.RecipeFlow.Resolv
     24 
     25 @resource_quantity """
     26 The amount and unit of the economic resource counted or inventoried.
     27 """
     28 @effort_quantity """
     29 The amount and unit of the work or use or citation effort-based
     30 action.  This is often a time duration, but also could be cycle counts
     31 or other measures of effort or usefulness.
     32 """
     33 @recipe_flow_resource """
     34 The resource definition referenced by this flow in the recipe.
     35 """
     36 @recipe_flow_resource_id "(`RecipeResource`) #{@recipe_flow_resource}"
     37 @action """
     38 Relates a process input or output to a verb, such as consume, produce,
     39 work, modify, etc.
     40 """
     41 @action_id "(`Action`) #{@action}"
     42 @recipe_input_of "Relates an input flow to its process in a recipe."
     43 @recipe_input_of_id "(`RecipeProcess`) #{@recipe_input_of}"
     44 @recipe_output_of "Relates an output flow to its process in a recipe."
     45 @recipe_output_of_id "(`RecipeProcess`) #{@recipe_output_of}"
     46 @recipe_clause_of "Relates a flow to its exchange agreement in a recipe."
     47 @recipe_clause_of_id "(`RecipeExchange`) #{@recipe_clause_of}"
     48 @note "A textual description or comment."
     49 
     50 @desc """
     51 The specification of a resource inflow to, or outflow from,
     52 a recipe process.
     53 """
     54 object :recipe_flow do
     55 	field :id, non_null(:id)
     56 
     57 	@desc @resource_quantity
     58 	field :resource_quantity, :measure,
     59 		resolve: &Resolv.resource_quantity/3
     60 
     61 	@desc @effort_quantity
     62 	field :effort_quantity, :measure,
     63 		resolve: &Resolv.effort_quantity/3
     64 
     65 	@desc @recipe_flow_resource
     66 	field :recipe_flow_resource, non_null(:recipe_resource),
     67 		resolve: &Resolv.recipe_flow_resource/3
     68 
     69 	@desc @action
     70 	field :action, non_null(:action), resolve: &Resolv.action/3
     71 
     72 	@desc @recipe_input_of
     73 	field :recipe_input_of, :recipe_process,
     74 		resolve: &Resolv.recipe_input_of/3
     75 
     76 	@desc @recipe_output_of
     77 	field :recipe_output_of, :recipe_process,
     78 		resolve: &Resolv.recipe_output_of/3
     79 
     80 	@desc @recipe_clause_of
     81 	field :recipe_clause_of, :recipe_exchange,
     82 		resolve: &Resolv.recipe_clause_of/3
     83 
     84 	@desc @note
     85 	field :note, :string
     86 end
     87 
     88 input_object :recipe_flow_create_params do
     89 	@desc @resource_quantity
     90 	field :resource_quantity, :imeasure
     91 
     92 	@desc @effort_quantity
     93 	field :effort_quantity, :imeasure
     94 
     95 	@desc @recipe_flow_resource_id
     96 	field :recipe_flow_resource_id, non_null(:id),
     97 		name: "recipe_flow_resource"
     98 
     99 	@desc @action_id
    100 	field :action_id, non_null(:string), name: "action"
    101 
    102 	@desc @recipe_input_of_id
    103 	field :recipe_input_of_id, :id, name: "recipe_input_of"
    104 
    105 	@desc @recipe_output_of_id
    106 	field :recipe_output_of_id, :id, name: "recipe_output_of"
    107 
    108 	@desc @recipe_clause_of_id
    109 	field :recipe_clause_of_id, :id, name: "recipe_clause_of"
    110 
    111 	@desc @note
    112 	field :note, :string
    113 end
    114 
    115 input_object :recipe_flow_update_params do
    116 	field :id, non_null(:id)
    117 
    118 	@desc @resource_quantity
    119 	field :resource_quantity, :imeasure
    120 
    121 	@desc @effort_quantity
    122 	field :effort_quantity, :imeasure
    123 
    124 	@desc @recipe_flow_resource_id
    125 	field :recipe_flow_resource_id, :id, name: "recipe_flow_resource"
    126 
    127 	@desc @action_id
    128 	field :action_id, :string, name: "action"
    129 
    130 	@desc @recipe_input_of_id
    131 	field :recipe_input_of_id, :id, name: "recipe_input_of"
    132 
    133 	@desc @recipe_output_of_id
    134 	field :recipe_output_of_id, :id, name: "recipe_output_of"
    135 
    136 	@desc @recipe_clause_of_id
    137 	field :recipe_clause_of_id, :id, name: "recipe_clause_of"
    138 
    139 	@desc @note
    140 	field :note, :string
    141 end
    142 
    143 object :recipe_flow_response do
    144 	field :recipe_flow, non_null(:recipe_flow)
    145 end
    146 
    147 object :recipe_flow_edge do
    148 	field :cursor, non_null(:id)
    149 	field :node, non_null(:recipe_flow)
    150 end
    151 
    152 object :recipe_flow_connection do
    153 	field :page_info, non_null(:page_info)
    154 	field :edges, non_null(list_of(non_null(:recipe_flow_edge)))
    155 end
    156 
    157 object :query_recipe_flow do
    158 	field :recipe_flow, :recipe_flow do
    159 		arg :id, non_null(:id)
    160 		resolve &Resolv.recipe_flow/2
    161 	end
    162 
    163 	field :recipe_flows, :recipe_flow_connection do
    164 		arg :first, :integer
    165 		arg :after, :id
    166 		arg :last, :integer
    167 		arg :before, :id
    168 		resolve &Resolv.recipe_flows/2
    169 	end
    170 end
    171 
    172 object :mutation_recipe_flow do
    173 	field :create_recipe_flow, non_null(:recipe_flow_response) do
    174 		arg :recipe_flow, non_null(:recipe_flow_create_params)
    175 		resolve &Resolv.create_recipe_flow/2
    176 	end
    177 
    178 	field :update_recipe_flow, non_null(:recipe_flow_response) do
    179 		arg :recipe_flow, non_null(:recipe_flow_update_params)
    180 		resolve &Resolv.update_recipe_flow/2
    181 	end
    182 
    183 	field :delete_recipe_flow, non_null(:boolean) do
    184 		arg :id, non_null(:id)
    185 		resolve &Resolv.delete_recipe_flow/2
    186 	end
    187 end
    188 end