From 2b175e128d508ac9121da088510891eeb39a99bc Mon Sep 17 00:00:00 2001 From: mkumar-02 Date: Mon, 15 Jul 2024 12:44:01 +0530 Subject: [PATCH 1/2] G2P Connect API: Added offset and order parameter in graphql schema Signed-off-by: mkumar-02 --- .../schemas/graphql_schema.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/g2p_registry_g2p_connect_rest_api/schemas/graphql_schema.py b/g2p_registry_g2p_connect_rest_api/schemas/graphql_schema.py index 56e94a7..4dd370f 100644 --- a/g2p_registry_g2p_connect_rest_api/schemas/graphql_schema.py +++ b/g2p_registry_g2p_connect_rest_api/schemas/graphql_schema.py @@ -57,8 +57,10 @@ class Query(graphene.ObjectType): get_registrants = graphene.List( Partner, required=True, - limit=graphene.Int(), is_group=graphene.Boolean(), + limit=graphene.Int(), + offset=graphene.Int(), + order=graphene.String(), **{ key: graphene.String() for key in Partner._meta.fields @@ -69,7 +71,9 @@ class Query(graphene.ObjectType): total_registrant_count = graphene.Int() @staticmethod - def resolve_get_registrants(root, info, is_group: bool = None, limit=None, **kwargs): + def resolve_get_registrants( + root, info, is_group: bool = None, limit=None, order=None, offset=None, **kwargs + ): global count domain = [(("is_registrant", "=", True))] @@ -81,7 +85,9 @@ def resolve_get_registrants(root, info, is_group: bool = None, limit=None, **kwa if value is not None: domain.append((key, "=", value)) - partners = info.context["env"]["res.partner"].sudo().search(domain, limit=limit) + partners = ( + info.context["env"]["res.partner"].sudo().search(domain, limit=limit, offset=offset, order=order) + ) count = len(partners) return partners From 1d46dfb30ea1a2c95862ec227687f36ec1c9cbad Mon Sep 17 00:00:00 2001 From: mkumar-02 Date: Mon, 15 Jul 2024 12:56:08 +0530 Subject: [PATCH 2/2] G2P Connect API: Fixed pre-commit issues Signed-off-by: mkumar-02 --- g2p_registry_g2p_connect_rest_api/schemas/graphql_schema.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/g2p_registry_g2p_connect_rest_api/schemas/graphql_schema.py b/g2p_registry_g2p_connect_rest_api/schemas/graphql_schema.py index fdac006..84b5c21 100644 --- a/g2p_registry_g2p_connect_rest_api/schemas/graphql_schema.py +++ b/g2p_registry_g2p_connect_rest_api/schemas/graphql_schema.py @@ -72,7 +72,9 @@ class Query(graphene.ObjectType): total_registrant_count = graphene.Int() @staticmethod - def resolve_get_registrants(root, info, last_sync_date=None, is_group: bool = None, limit=None, order=None, offset=None, **kwargs): + def resolve_get_registrants( + root, info, last_sync_date=None, is_group: bool = None, limit=None, order=None, offset=None, **kwargs + ): global count domain = [(("is_registrant", "=", True))]