type.ex (3971B)
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.Scenario.Type do 19 @moduledoc false 20 21 use Absinthe.Schema.Notation 22 23 alias Zenflows.VF.Scenario.Resolv 24 25 @name """ 26 An informal or formal textual identifier for a scenario. Does not 27 imply uniqueness. 28 """ 29 @note "A textual description or comment." 30 @has_beginning """ 31 The beginning date/time of the scenario, often the beginning of an 32 accounting period. 33 """ 34 @has_end """ 35 The ending date/time of the scenario, often the end of an accounting 36 period. 37 """ 38 @defined_as """ 39 The scenario definition for this scenario, for example yearly budget. 40 """ 41 @defined_as_id "(`ScenarioDefinition`) #{@defined_as}" 42 @refinement_of """ 43 This scenario refines another scenario, often as time moves closer or 44 for more detail. 45 """ 46 @refinement_of_id "(`Scenario`) #{@refinement_of}" 47 48 @desc """ 49 An estimated or analytical logical collection of higher level processes 50 used for budgeting, analysis, plan refinement, etc." 51 """ 52 object :scenario do 53 field :id, non_null(:id) 54 55 @desc @name 56 field :name, non_null(:string) 57 58 @desc @note 59 field :note, :string 60 61 @desc @has_beginning 62 field :has_beginning, :datetime 63 64 @desc @has_end 65 field :has_end, :datetime 66 67 @desc @defined_as 68 field :defined_as, :scenario_definition, 69 resolve: &Resolv.defined_as/3 70 71 @desc @refinement_of 72 field :refinement_of, :scenario, resolve: &Resolv.refinement_of/3 73 end 74 75 input_object :scenario_create_params do 76 @desc @name 77 field :name, non_null(:string) 78 79 @desc @note 80 field :note, :string 81 82 @desc @has_beginning 83 field :has_beginning, :datetime 84 85 @desc @has_end 86 field :has_end, :datetime 87 88 @desc @defined_as_id 89 field :defined_as_id, :id, name: "defined_as" 90 91 @desc @refinement_of_id 92 field :refinement_of_id, :id, name: "refinement_of" 93 end 94 95 input_object :scenario_update_params do 96 field :id, non_null(:id) 97 98 @desc @name 99 field :name, :string 100 101 @desc @note 102 field :note, :string 103 104 @desc @has_beginning 105 field :has_beginning, :datetime 106 107 @desc @has_end 108 field :has_end, :datetime 109 110 @desc @defined_as_id 111 field :defined_as_id, :id, name: "defined_as" 112 113 @desc @refinement_of_id 114 field :refinement_of_id, :id, name: "refinement_of" 115 end 116 117 object :scenario_response do 118 field :scenario, non_null(:scenario) 119 end 120 121 object :scenario_edge do 122 field :cursor, non_null(:id) 123 field :node, non_null(:scenario) 124 end 125 126 object :scenario_connection do 127 field :page_info, non_null(:page_info) 128 field :edges, non_null(list_of(non_null(:scenario_edge))) 129 end 130 131 object :query_scenario do 132 field :scenario, :scenario do 133 arg :id, non_null(:id) 134 resolve &Resolv.scenario/2 135 end 136 137 field :scenarios, :scenario_connection do 138 arg :first, :integer 139 arg :after, :id 140 arg :last, :integer 141 arg :before, :id 142 resolve &Resolv.scenarios/2 143 end 144 end 145 146 object :mutation_scenario do 147 field :create_scenario, non_null(:scenario_response) do 148 arg :scenario, non_null(:scenario_create_params) 149 resolve &Resolv.create_scenario/2 150 end 151 152 field :update_scenario, non_null(:scenario_response) do 153 arg :scenario, non_null(:scenario_update_params) 154 resolve &Resolv.update_scenario/2 155 end 156 157 field :delete_scenario, non_null(:boolean) do 158 arg :id, non_null(:id) 159 resolve &Resolv.delete_scenario/2 160 end 161 end 162 end