Commit d79792e3 authored by Mayel's avatar Mayel

more missing fields

parent dd976d9a
Pipeline #216080587 failed with stage
in 1 minute and 1 second
......@@ -5,7 +5,6 @@ defmodule ValueFlows.Hydration do
UsersResolver
}
alias ValueFlows.Observation.{
Process,
EconomicResource
......@@ -33,7 +32,7 @@ defmodule ValueFlows.Hydration do
],
inventoried_economic_resources: [
resolve: &ValueFlows.Observation.EconomicResource.GraphQL.agent_resources/3
],
]
}
%{
......@@ -85,7 +84,15 @@ defmodule ValueFlows.Hydration do
],
creator: [
resolve: &UsersResolver.creator_edge/3
]
},
proposed_to: %{
proposed_to: [
resolve: &ValueFlows.Proposal.ProposedToGraphQL.proposed_to_agent/3
],
fetch_proposed_edge: [
resolve: &ValueFlows.Proposal.ProposedToGraphQL.fetch_proposed_edge/3
]
},
intent: %{
canonical_url: [
......@@ -138,11 +145,11 @@ defmodule ValueFlows.Hydration do
],
output_of: [
resolve: &ValueFlows.Planning.Intent.GraphQL.fetch_output_of_edge/3
],
]
},
claim: %{
action: [
resolve: &ValueFlows.Knowledge.Action.GraphQL.action_edge/3,
resolve: &ValueFlows.Knowledge.Action.GraphQL.action_edge/3
],
provider: [
resolve: &ValueFlows.Util.GraphQL.fetch_provider_edge/3
......@@ -157,17 +164,17 @@ defmodule ValueFlows.Hydration do
resolve: &ValueFlows.Util.GraphQL.effort_quantity_edge/3
],
resource_conforms_to: [
resolve: &ValueFlows.Util.GraphQL.fetch_resource_conforms_to_edge/3,
resolve: &ValueFlows.Util.GraphQL.fetch_resource_conforms_to_edge/3
],
triggered_by: [
resolve: &ValueFlows.Claim.GraphQL.fetch_triggered_by_edge/3,
resolve: &ValueFlows.Claim.GraphQL.fetch_triggered_by_edge/3
],
in_scope_of: [
resolve: &ValueFlows.Util.GraphQL.scope_edge/3,
resolve: &ValueFlows.Util.GraphQL.scope_edge/3
],
creator: [
resolve: &UsersResolver.creator_edge/3
],
]
},
economic_event: %{
canonical_url: [
......@@ -183,7 +190,7 @@ defmodule ValueFlows.Hydration do
resolve: &ValueFlows.Knowledge.Action.GraphQL.action_edge/3
],
resource_conforms_to: [
resolve: &ValueFlows.Util.GraphQL.fetch_resource_conforms_to_edge/3,
resolve: &ValueFlows.Util.GraphQL.fetch_resource_conforms_to_edge/3
],
resource_quantity: [
resolve: &ValueFlows.Util.GraphQL.resource_quantity_edge/3
......@@ -256,7 +263,8 @@ defmodule ValueFlows.Hydration do
resolve: &ValueFlows.Util.GraphQL.onhand_quantity_edge/3
],
primary_accountable: [
resolve: &ValueFlows.Observation.EconomicResource.GraphQL.fetch_primary_accountable_edge/3
resolve:
&ValueFlows.Observation.EconomicResource.GraphQL.fetch_primary_accountable_edge/3
],
unit_of_effort: [
resolve: &ValueFlows.Observation.EconomicResource.GraphQL.fetch_unit_of_effort_edge/3
......@@ -306,6 +314,12 @@ defmodule ValueFlows.Hydration do
resolve: &ValueFlows.Observation.Process.GraphQL.fetch_based_on_edge/3
]
},
resource_specification: %{
default_unit_of_effort: [
resolve:
&ValueFlows.Knowledge.ResourceSpecification.GraphQL.fetch_default_unit_of_effort_edge/3
]
},
# start Query resolvers
value_flows_query: %{
......@@ -340,10 +354,10 @@ defmodule ValueFlows.Hydration do
# Claim
claim: [
resolve: &ValueFlows.Claim.GraphQL.claim/2,
resolve: &ValueFlows.Claim.GraphQL.claim/2
],
claims: [
resolve: &ValueFlows.Claim.GraphQL.claims/2,
resolve: &ValueFlows.Claim.GraphQL.claims/2
],
# Knowledge
......@@ -441,7 +455,7 @@ defmodule ValueFlows.Hydration do
# start Mutation resolvers
value_flows_mutation: %{
create_claim: [
resolve: &ValueFlows.Claim.GraphQL.create_claim/2,
resolve: &ValueFlows.Claim.GraphQL.create_claim/2
],
create_intent: [
resolve: &ValueFlows.Planning.Intent.GraphQL.create_intent/2
......@@ -465,7 +479,7 @@ defmodule ValueFlows.Hydration do
# resolve: &ValueFlows.Knowledge.Action.GraphQL.create_action/2
# ],
update_claim: [
resolve: &ValueFlows.Claim.GraphQL.update_claim/2,
resolve: &ValueFlows.Claim.GraphQL.update_claim/2
],
update_intent: [
resolve: &ValueFlows.Planning.Intent.GraphQL.update_intent/2
......@@ -483,7 +497,7 @@ defmodule ValueFlows.Hydration do
resolve: &ValueFlows.Observation.Process.GraphQL.update_process/2
],
delete_claim: [
resolve: &ValueFlows.Claim.GraphQL.delete_claim/2,
resolve: &ValueFlows.Claim.GraphQL.delete_claim/2
],
delete_intent: [
resolve: &ValueFlows.Planning.Intent.GraphQL.delete_intent/2
......
......@@ -54,6 +54,16 @@ defmodule ValueFlows.Knowledge.ResourceSpecification.GraphQL do
])
end
def fetch_default_unit_of_effort_edge(%{default_unit_of_effort_id: id} = thing, _, _)
when not is_nil(id) do
thing = Repo.preload(thing, :default_unit_of_effort)
{:ok, Map.get(thing, :default_unit_of_effort)}
end
def fetch_default_unit_of_effort_edge(_, _, _) do
{:ok, nil}
end
def resource_specs_filtered(page_opts, _) do
resource_specs_filter(page_opts, [])
end
......
......@@ -39,6 +39,8 @@ defmodule ValueFlows.Knowledge.ResourceSpecification do
field(:deleted_at, :utc_datetime_usec)
has_many(:conforming_resources, ValueFlows.Observation.EconomicResource, foreign_key: :conforms_to)
many_to_many(:tags, CommonsPub.Tag.Taggable,
join_through: "tags_things",
unique: true,
......
......@@ -20,13 +20,32 @@ defmodule ValueFlows.Proposal.ProposedToGraphQL do
Proposals.one_proposed_to([:default, id: id])
end
def published_to_edge(%{id: proposal_id}, _, _info) do
Proposals.many_proposed_to([:default, proposed_id: proposal_id])
def published_to_edge(%{id: id}, _, _info) when not is_nil(id) do
Proposals.many_proposed_to([:default, proposed_id: id])
end
def published_to_edge(_, _, _info) do
{:ok, nil}
end
def proposed_to_agent(%{proposed_to_id: id}, _, _info) when not is_nil(id) do
{:ok, ValueFlows.Agent.Agents.agent(id, nil)}
end
def proposed_to_agent(_, _, _info) do
{:ok, nil}
end
def fetch_proposed_edge(%{proposed_id: id} = thing, _, _)
when is_binary(id) do
thing = Repo.preload(thing, :proposed)
{:ok, Map.get(thing, :proposed)}
end
def fetch_proposed_edge(_, _, _) do
{:ok, nil}
end
def propose_to(%{proposed_to: agent_id, proposed: proposed_id}, info) do
with {:ok, _} <- GraphQL.current_user_or_not_logged_in(info),
{:ok, pointer} <- Pointers.one(id: agent_id),
......
......@@ -2836,7 +2836,15 @@ type Proposal {
A textual description or comment.
"""
note: String
"""
Intent(s) published as part of to this proposal
"""
publishes: [ProposedIntent!]
"""
Which Agent(s) (if any were specified) was this proposed to?
"""
publishedTo: [ProposedTo!]
"""
......
......@@ -14,15 +14,18 @@ defmodule CommonsPub.Web.GraphQL.QueryHelper do
@spec run_query_id(any(), module(), atom(), non_neg_integer(), Keyword.t(), boolean()) ::
String.t()
def run_query_id(id, schema, type, nesting \\ 1, override_fun \\ nil, debug \\ nil) do
with {:ok, go} <-
query_with_id(schema, type, nesting, override_fun)
|> maybe_debug(debug)
|> Absinthe.run(schema, variables: %{"id" => id}) do
maybe_debug(go, debug)
q = query_with_id(schema, type, nesting, override_fun)
with {:ok, go} <- Absinthe.run(q, schema, variables: %{"id" => id}) do
maybe_debug(q, go, debug)
go |> Map.get(:data) |> Map.get(Atom.to_string(type))
else e ->
maybe_debug(q, e, true)
e
end
end
......@@ -71,7 +74,6 @@ defmodule CommonsPub.Web.GraphQL.QueryHelper do
|> apply_overrides(override_fun)
|> format_fields(type, 10, schema)
|> List.to_string()
end
@doc """
......@@ -219,18 +221,16 @@ defmodule CommonsPub.Web.GraphQL.QueryHelper do
def camelize(type), do: Absinthe.Utils.camelize(to_string(type), lower: true)
def maybe_debug(%{errors: errors} = obj, debug) do
Logger.warn("GraphQL errors:")
IO.inspect(errors)
maybe_debug(Map.get(obj, :data), debug)
def maybe_debug(q, %{errors: errors} = obj, _) do
Logger.warn("The below GraphQL query had some errors in the response:")
IO.inspect(errors: errors)
maybe_debug(q, Map.get(obj, :data), true)
end
def maybe_debug(obj, debug) do
def maybe_debug(q, obj, debug) do
if(debug || CommonsPub.Config.get([:logging, :tests_output_graphql])) do
IO.inspect(graphql: obj)
IO.inspect(graphql_query: q)
IO.inspect(graphql_response: obj)
end
obj
end
end
......@@ -16,7 +16,7 @@ defmodule ValueFlows.Planning.Intent.GraphQLTest do
import ValueFlows.Test.Faking
alias ValueFlows.Planning.Intent.Intents
@debug true
@debug false
@schema CommonsPub.Web.GraphQL.Schema
describe "intent" do
......@@ -47,7 +47,7 @@ defmodule ValueFlows.Planning.Intent.GraphQLTest do
in_scope_of: [parent.id]
})
IO.inspect(intent: intent)
# IO.inspect(intent: intent)
proposal = fake_proposal!(user)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment