type.ex (2539B)
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.Unit.Type do 19 @moduledoc false 20 21 use Absinthe.Schema.Notation 22 23 alias Zenflows.VF.Unit.Resolv 24 25 @label "A human readable label for the unit, can be language specific." 26 @symbol "A standard display symbol for a unit of measure." 27 28 @desc """ 29 Defines a unit of measurement, along with its display symbol. From OM2 30 vocabulary. 31 """ 32 object :unit do 33 field :id, non_null(:id) 34 35 @desc @label 36 field :label, non_null(:string) 37 38 @desc @symbol 39 field :symbol, non_null(:string) 40 end 41 42 input_object :unit_create_params do 43 @desc @label 44 field :label, non_null(:string) 45 46 @desc @symbol 47 field :symbol, non_null(:string) 48 end 49 50 input_object :unit_update_params do 51 field :id, non_null(:id) 52 53 @desc @label 54 field :label, :string 55 56 @desc @symbol 57 field :symbol, :string 58 end 59 60 object :unit_response do 61 field :unit, non_null(:unit) 62 end 63 64 object :unit_edge do 65 field :cursor, non_null(:id) 66 field :node, non_null(:unit) 67 end 68 69 object :unit_connection do 70 field :page_info, non_null(:page_info) 71 field :edges, non_null(list_of(non_null(:unit_edge))) 72 end 73 74 object :query_unit do 75 field :unit, :unit do 76 arg :id, non_null(:id) 77 resolve &Resolv.unit/2 78 end 79 80 field :units, :unit_connection do 81 arg :first, :integer 82 arg :after, :id 83 arg :last, :integer 84 arg :before, :id 85 resolve &Resolv.units/2 86 end 87 end 88 89 object :mutation_unit do 90 field :create_unit, non_null(:unit_response) do 91 arg :unit, non_null(:unit_create_params) 92 resolve &Resolv.create_unit/2 93 end 94 95 field :update_unit, non_null(:unit_response) do 96 arg :unit, non_null(:unit_update_params) 97 resolve &Resolv.update_unit/2 98 end 99 100 field :delete_unit, non_null(:boolean) do 101 arg :id, non_null(:id) 102 resolve &Resolv.delete_unit/2 103 end 104 end 105 end