zf

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

type.ex (4458B)


      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.AgentRelationship.Type do
     19 @moduledoc false
     20 
     21 use Absinthe.Schema.Notation
     22 
     23 alias Zenflows.VF.AgentRelationship.Resolv
     24 
     25 @subject """
     26 The subject of a relationship between two agents.  For example, if Mary
     27 is a member of a group, then Mary is the subject.
     28 """
     29 @subject_id "(`Agent`) #{@subject}"
     30 @object """
     31 The object of a relationship between two agents.  For example, if Mary
     32 is a member of a group, then the group is the object.
     33 """
     34 @object_id "(`Agent`) #{@object}"
     35 @relationship "A kind of relationship that exists between two agents."
     36 @relationship_id "(`AgentRelationshipRole`) #{@relationship}"
     37 #@in_scope_of """
     38 #Grouping around something to create a boundary or context, used for
     39 #documenting, accounting, planning.
     40 #"""
     41 @note "A textual description or comment."
     42 
     43 @desc """
     44 The role of an economic relationship that exists between 2 agents,
     45 such as member, trading partner.
     46 """
     47 object :agent_relationship do
     48 	field :id, non_null(:id)
     49 
     50 	@desc @subject
     51 	field :subject, non_null(:agent), resolve: &Resolv.subject/3
     52 
     53 	@desc @object
     54 	field :object, non_null(:agent), resolve: &Resolv.object/3
     55 
     56 	@desc @relationship
     57 	field :relationship, non_null(:agent_relationship_role),
     58 		resolve: &Resolv.relationship/3
     59 
     60 	#@desc @in_scope_of
     61 	#field :in_scope_of, list_of(non_null(:accounting_scope))
     62 
     63 	@desc @note
     64 	field :note, :string
     65 end
     66 
     67 input_object :agent_relationship_create_params do
     68 	@desc @subject_id
     69 	field :subject_id, non_null(:id), name: "subject"
     70 
     71 	@desc @object_id
     72 	field :object_id, non_null(:id), name: "object"
     73 
     74 	@desc @relationship_id
     75 	field :relationship_id, non_null(:id), name: "relationship"
     76 
     77 	#@desc @in_scope_of
     78 	#field :in_scope_of, list_of(non_null(:accounting_scope))
     79 
     80 	@desc @note
     81 	field :note, :string
     82 end
     83 
     84 input_object :agent_relationship_update_params do
     85 	field :id, non_null(:id)
     86 
     87 	@desc @subject_id
     88 	field :subject_id, :id, name: "subject"
     89 
     90 	@desc @object_id
     91 	field :object_id, :id, name: "object"
     92 
     93 	@desc @relationship_id
     94 	field :relationship_id, :id, name: "relationship"
     95 
     96 	#@desc @in_scope_of
     97 	#field :in_scope_of, list_of(non_null(:accounting_scope))
     98 
     99 	@desc @note
    100 	field :note, :string
    101 end
    102 
    103 object :agent_relationship_response do
    104 	field :agent_relationship, non_null(:agent_relationship)
    105 end
    106 
    107 object :agent_relationship_edge do
    108 	field :cursor, non_null(:id)
    109 	field :node, non_null(:agent_relationship)
    110 end
    111 
    112 object :agent_relationship_connection do
    113 	field :page_info, non_null(:page_info)
    114 	field :edges, non_null(list_of(non_null(:agent_relationship_edge)))
    115 end
    116 
    117 object :query_agent_relationship do
    118 	@desc "Retrieve details of an agent relationship by its ID."
    119 	field :agent_relationship, :agent_relationship do
    120 		arg :id, non_null(:id)
    121 		resolve &Resolv.agent_relationship/2
    122 	end
    123 
    124 	@desc """
    125 	Retrieve details of all the relationships between all agents
    126 	registered in this collaboration space.
    127 	"""
    128 	field :agent_relationships, :agent_relationship_connection do
    129 		arg :first, :integer
    130 		arg :after, :id
    131 		arg :last, :integer
    132 		arg :before, :id
    133 		resolve &Resolv.agent_relationships/2
    134 	end
    135 end
    136 
    137 object :mutation_agent_relationship do
    138 	field :create_agent_relationship, non_null(:agent_relationship_response) do
    139 		arg :relationship, non_null(:agent_relationship_create_params)
    140 		resolve &Resolv.create_agent_relationship/2
    141 	end
    142 
    143 	field :update_agent_relationship, non_null(:agent_relationship_response) do
    144 		arg :relationship, non_null(:agent_relationship_update_params)
    145 		resolve &Resolv.update_agent_relationship/2
    146 	end
    147 
    148 	field :delete_agent_relationship, non_null(:boolean) do
    149 		arg :id, non_null(:id)
    150 		resolve &Resolv.delete_agent_relationship/2
    151 	end
    152 end
    153 end