From bcc6bc0d27da340617b657da3ebfea74a810d8eb Mon Sep 17 00:00:00 2001 From: Endre Oma Date: Tue, 9 May 2017 21:43:20 +0200 Subject: [PATCH] Fix: objects with composite primary keys should have correct id --- graphene_sqlalchemy/types.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/graphene_sqlalchemy/types.py b/graphene_sqlalchemy/types.py index 70729ed6..74d5cc91 100644 --- a/graphene_sqlalchemy/types.py +++ b/graphene_sqlalchemy/types.py @@ -141,5 +141,6 @@ def get_node(cls, id, context, info): def resolve_id(self, args, context, info): graphene_type = info.parent_type.graphene_type if is_node(graphene_type): - return self.__mapper__.primary_key_from_instance(self)[0] + keys = self.__mapper__.primary_key_from_instance(self) + return tuple(keys) if len(keys) > 1 else keys[0] return getattr(self, graphene_type._meta.id, None)