type.ex (3215B)
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.ProductBatch.Type do 19 @moduledoc false 20 21 use Absinthe.Schema.Notation 22 23 alias Zenflows.VF.ProductBatch.Resolv 24 25 @batch_number """ 26 An informal or formal textual identifier for a recipe exchange. Does not 27 imply uniqueness. 28 """ 29 @expiry_date "A textual description or comment." 30 @production_date "" 31 32 @desc """ 33 A lot or batch, defining a resource produced at the same 34 time in the same way. From DataFoodConsortium vocabulary 35 https://datafoodconsortium.gitbook.io/dfc-standard-documentation/. 36 """ 37 object :product_batch do 38 field :id, non_null(:id) 39 40 @desc @batch_number 41 field :batch_number, non_null(:string) 42 43 @desc @expiry_date 44 field :expiry_date, :datetime 45 46 @desc @production_date 47 field :production_date, :datetime 48 end 49 50 input_object :product_batch_create_params do 51 @desc @batch_number 52 field :batch_number, non_null(:string) 53 54 @desc @expiry_date 55 field :expiry_date, :datetime 56 57 @desc @production_date 58 field :production_date, :datetime 59 end 60 61 input_object :product_batch_update_params do 62 field :id, non_null(:id) 63 64 @desc @batch_number 65 field :batch_number, :string 66 67 @desc @expiry_date 68 field :expiry_date, :datetime 69 70 @desc @production_date 71 field :production_date, :datetime 72 end 73 74 object :product_batch_response do 75 field :product_batch, non_null(:product_batch) 76 end 77 78 object :product_batch_edge do 79 field :cursor, non_null(:id) 80 field :node, non_null(:product_batch) 81 end 82 83 object :product_batch_connection do 84 field :page_info, non_null(:page_info) 85 field :edges, non_null(list_of(non_null(:product_batch_edge))) 86 end 87 88 object :query_product_batch do 89 field :product_batch, :product_batch do 90 arg :id, non_null(:id) 91 resolve &Resolv.product_batch/2 92 end 93 94 field :product_batches, :product_batch_connection do 95 arg :first, :integer 96 arg :after, :id 97 arg :last, :integer 98 arg :before, :id 99 resolve &Resolv.product_batches/2 100 end 101 end 102 103 object :mutation_product_batch do 104 field :create_product_batch, non_null(:product_batch_response) do 105 arg :product_batch, non_null(:product_batch_create_params) 106 resolve &Resolv.create_product_batch/2 107 end 108 109 field :update_product_batch, non_null(:product_batch_response) do 110 arg :product_batch, non_null(:product_batch_update_params) 111 resolve &Resolv.update_product_batch/2 112 end 113 114 field :delete_product_batch, non_null(:boolean) do 115 arg :id, non_null(:id) 116 resolve &Resolv.delete_product_batch/2 117 end 118 end 119 end