Commit 1310b151 authored by Mayel's avatar Mayel

weird issue hydrating conforming_resources

parent d79792e3
Pipeline #216084214 failed with stage
in 1 minute and 5 seconds
......@@ -318,7 +318,10 @@ defmodule ValueFlows.Hydration do
default_unit_of_effort: [
resolve:
&ValueFlows.Knowledge.ResourceSpecification.GraphQL.fetch_default_unit_of_effort_edge/3
]
],
# conforming_resources: [
# resolve: %ValueFlows.Knowledge.ResourceSpecification.GraphQL.fetch_conforming_resources_edge/3
# ]
},
# start Query resolvers
......
# SPDX-License-Identifier: AGPL-3.0-only
defmodule ValueFlows.Knowledge.ResourceSpecification.GraphQL do
require Logger
alias CommonsPub.{GraphQL, Repo}
alias CommonsPub.GraphQL.{
......@@ -50,7 +48,7 @@ defmodule ValueFlows.Knowledge.ResourceSpecification.GraphQL do
def all_resource_specs(_, _) do
ResourceSpecifications.many([
:default,
:default
])
end
......@@ -64,6 +62,10 @@ defmodule ValueFlows.Knowledge.ResourceSpecification.GraphQL do
{:ok, nil}
end
def fetch_conforming_resources_edge(%{conforms_to: id}, page_opts, info) when not is_nil(id) do
ValueFlows.Observation.EconomicResource.GraphQL.spec_conforms_to_resources(%{conforms_to: id}, page_opts, info)
end
def resource_specs_filtered(page_opts, _) do
resource_specs_filter(page_opts, [])
end
......@@ -87,7 +89,6 @@ defmodule ValueFlows.Knowledge.ResourceSpecification.GraphQL do
_,
filters_acc
) do
# finally, if there's no more known params to acumulate, query with the filters
ResourceSpecifications.many(filters_acc)
end
......@@ -113,7 +114,7 @@ defmodule ValueFlows.Knowledge.ResourceSpecification.GraphQL do
ResourceSpecifications.one([
:default,
user: GraphQL.current_user(info),
id: id,
id: id
])
end
......
......@@ -84,6 +84,8 @@ defmodule ValueFlows.Observation.EconomicResource.GraphQL do
})
end
def track(_, _, _), do: {:ok, nil}
def trace(%{id: id}, _, info) do
ResolveField.run(%ResolveField{
module: __MODULE__,
......@@ -92,6 +94,7 @@ defmodule ValueFlows.Observation.EconomicResource.GraphQL do
info: info
})
end
def trace(_, _, _), do: {:ok, nil}
def resources_filtered(page_opts, _ \\ nil) do
# IO.inspect(resources_filtered: page_opts)
......@@ -291,6 +294,33 @@ defmodule ValueFlows.Observation.EconomicResource.GraphQL do
)
end
def spec_conforms_to_resources(%{conforms_to: spec_id}, %{} = _page_opts, _info) do
EconomicResources.many([conforms_to: spec_id])
end
def spec_conforms_to_resources_edge(%{conforms_to: spec_id}, %{} = page_opts, info) do
ResolvePages.run(%ResolvePages{
module: __MODULE__,
fetcher: :fetch_spec_conforms_to_resources_edge,
context: spec_id,
page_opts: page_opts,
info: info
})
end
def fetch_spec_conforms_to_resources_edge(page_opts, info, ids) do
list_resources(
page_opts,
[
:default,
conforms_to: ids,
user: GraphQL.current_user(info)
],
nil,
nil
)
end
def list_resources(page_opts, base_filters, _data_filters, _cursor_type) do
FetchPage.run(%FetchPage{
queries: Queries,
......@@ -353,9 +383,7 @@ defmodule ValueFlows.Observation.EconomicResource.GraphQL do
{:ok, Map.get(thing, :conforms_to)}
end
def fetch_conforms_to_edge(_, _, _) do
{:ok, nil}
end
def fetch_conforms_to_edge(_, _, _), do: {:ok, nil}
def fetch_track_resource(_, id) do
EconomicResources.track(id)
......@@ -369,6 +397,7 @@ defmodule ValueFlows.Observation.EconomicResource.GraphQL do
thing = EconomicResources.preload_state(thing)
{:ok, Map.get(thing, :state)}
end
def fetch_state_edge(_, _, _), do: {:ok, nil}
def create_resource(%{new_inventoried_resource: resource_attrs}, info) do
......
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