Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
See what's new at GitLab
4
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
C
CommonsPub Federated Server
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
10
Issues
10
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
1
Merge Requests
1
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Bonfire
CommonsPub Federated Server
Commits
d79792e3
Commit
d79792e3
authored
Nov 14, 2020
by
Mayel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more missing fields
parent
dd976d9a
Pipeline
#216080587
failed with stage
in 1 minute and 1 second
Changes
7
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
87 additions
and
34 deletions
+87
-34
lib/extensions/value_flows/hydration.ex
lib/extensions/value_flows/hydration.ex
+29
-15
lib/extensions/value_flows/knowledge/resource_specification/graphql.ex
...s/value_flows/knowledge/resource_specification/graphql.ex
+10
-0
lib/extensions/value_flows/knowledge/resource_specification/resource_spec.ex
...e_flows/knowledge/resource_specification/resource_spec.ex
+2
-0
lib/extensions/value_flows/proposal/proposed_to_graphql.ex
lib/extensions/value_flows/proposal/proposed_to_graphql.ex
+21
-2
lib/extensions/value_flows/schema.gql
lib/extensions/value_flows/schema.gql
+8
-0
lib/mixology/graphql/query_helper.ex
lib/mixology/graphql/query_helper.ex
+15
-15
test/value_flows/planning/intent/intent_graphql_test.exs
test/value_flows/planning/intent/intent_graphql_test.exs
+2
-2
No files found.
lib/extensions/value_flows/hydration.ex
View file @
d79792e3
...
...
@@ -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
...
...
lib/extensions/value_flows/knowledge/resource_specification/graphql.ex
View file @
d79792e3
...
...
@@ -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
...
...
lib/extensions/value_flows/knowledge/resource_specification/resource_spec.ex
View file @
d79792e3
...
...
@@ -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
,
...
...
lib/extensions/value_flows/proposal/proposed_to_graphql.ex
View file @
d79792e3
...
...
@@ -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
),
...
...
lib/extensions/value_flows/schema.gql
View file @
d79792e3
...
...
@@ -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
!]
"""
...
...
lib/mixology/graphql/query_helper.ex
View file @
d79792e3
...
...
@@ -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
test/value_flows/planning/intent/intent_graphql_test.exs
View file @
d79792e3
...
...
@@ -16,7 +16,7 @@ defmodule ValueFlows.Planning.Intent.GraphQLTest do
import
ValueFlows
.
Test
.
Faking
alias
ValueFlows
.
Planning
.
Intent
.
Intents
@debug
tru
e
@debug
fals
e
@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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment