Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
GÉANT Service Orchestrator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GÉANT Orchestration and Automation Team
GAP
GÉANT Service Orchestrator
Commits
966054c1
Commit
966054c1
authored
6 months ago
by
Mohammad Torkashvand
Browse files
Options
Downloads
Patches
Plain Diff
add custom customer type and resolver to the graphql
parent
6689df7d
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Pipeline
#90996
failed
6 months ago
Stage: tox
Stage: documentation
Stage: sonarqube
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
gso/__init__.py
+2
-1
2 additions, 1 deletion
gso/__init__.py
gso/graphql_api/resolvers/__init__.py
+1
-0
1 addition, 0 deletions
gso/graphql_api/resolvers/__init__.py
gso/graphql_api/resolvers/customer.py
+30
-0
30 additions, 0 deletions
gso/graphql_api/resolvers/customer.py
with
33 additions
and
1 deletion
gso/__init__.py
+
2
−
1
View file @
966054c1
...
@@ -17,6 +17,7 @@ import gso.workflows # noqa: F401
...
@@ -17,6 +17,7 @@ import gso.workflows # noqa: F401
from
gso.api
import
router
as
api_router
from
gso.api
import
router
as
api_router
from
gso.auth.oidc
import
oidc_instance
from
gso.auth.oidc
import
oidc_instance
from
gso.auth.opa
import
graphql_opa_instance
,
opa_instance
from
gso.auth.opa
import
graphql_opa_instance
,
opa_instance
from
gso.graphql_api.resolvers.customer
import
custom_subscription_interface
from
gso.graphql_api.types
import
GSO_SCALAR_OVERRIDES
from
gso.graphql_api.types
import
GSO_SCALAR_OVERRIDES
from
gso.settings
import
load_oss_params
from
gso.settings
import
load_oss_params
...
@@ -35,7 +36,7 @@ def init_gso_app() -> OrchestratorCore:
...
@@ -35,7 +36,7 @@ def init_gso_app() -> OrchestratorCore:
app
.
register_authentication
(
oidc_instance
)
app
.
register_authentication
(
oidc_instance
)
app
.
register_authorization
(
opa_instance
)
app
.
register_authorization
(
opa_instance
)
app
.
register_graphql_authorization
(
graphql_opa_instance
)
app
.
register_graphql_authorization
(
graphql_opa_instance
)
app
.
register_graphql
()
app
.
register_graphql
(
subscription_interface
=
custom_subscription_interface
)
app
.
include_router
(
api_router
,
prefix
=
"
/api
"
)
app
.
include_router
(
api_router
,
prefix
=
"
/api
"
)
if
app_settings
.
EXECUTOR
==
ExecutorType
.
WORKER
:
if
app_settings
.
EXECUTOR
==
ExecutorType
.
WORKER
:
...
...
This diff is collapsed.
Click to expand it.
gso/graphql_api/resolvers/__init__.py
0 → 100644
+
1
−
0
View file @
966054c1
"""
resolvers module.
"""
This diff is collapsed.
Click to expand it.
gso/graphql_api/resolvers/customer.py
0 → 100644
+
30
−
0
View file @
966054c1
"""
This module contains the resolver for the customer field in the subscription and process types.
"""
import
strawberry
from
orchestrator.graphql.schemas.customer
import
CustomerType
from
orchestrator.graphql.schemas.process
import
ProcessType
from
orchestrator.graphql.schemas.subscription
import
SubscriptionInterface
from
orchestrator.graphql.utils.override_class
import
override_class
from
gso.services.partners
import
get_partner_by_id
async
def
resolve_customer
(
root
:
CustomerType
)
->
CustomerType
:
"""
Resolve the customer field for a subscription or process.
"""
partner
=
get_partner_by_id
(
root
.
customer_id
)
return
CustomerType
(
customer_id
=
partner
.
partner_id
,
fullname
=
partner
.
name
,
shortcode
=
partner
.
email
,
)
customer_field
=
strawberry
.
field
(
resolver
=
resolve_customer
,
description
=
"
Returns customer of a subscription
"
,
)
customer_field
.
name
=
"
customer
"
override_class
(
ProcessType
,
[
customer_field
])
custom_subscription_interface
=
override_class
(
SubscriptionInterface
,
[
customer_field
])
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment