Skip to content

Commit c1a0cae

Browse files
authored
Merge pull request #48 from eoma/fix-recognize-composite-primary-keys
Fix: objects with composite primary keys should have correct id
2 parents 030e5e1 + bcc6bc0 commit c1a0cae

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

graphene_sqlalchemy/types.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,5 +141,6 @@ def get_node(cls, id, context, info):
141141
def resolve_id(self, args, context, info):
142142
graphene_type = info.parent_type.graphene_type
143143
if is_node(graphene_type):
144-
return self.__mapper__.primary_key_from_instance(self)[0]
144+
keys = self.__mapper__.primary_key_from_instance(self)
145+
return tuple(keys) if len(keys) > 1 else keys[0]
145146
return getattr(self, graphene_type._meta.id, None)

0 commit comments

Comments
 (0)