File tree Expand file tree Collapse file tree 2 files changed +3
-1
lines changed
graphene/contrib/sqlalchemy Expand file tree Collapse file tree 2 files changed +3
-1
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ class SQLAlchemyOptions(ObjectTypeOptions):
10
10
def __init__ (self , * args , ** kwargs ):
11
11
super (SQLAlchemyOptions , self ).__init__ (* args , ** kwargs )
12
12
self .model = None
13
+ self .identifier = None
13
14
self .valid_attrs += VALID_ATTRS
14
15
self .only_fields = None
15
16
self .exclude_fields = []
Original file line number Diff line number Diff line change @@ -113,8 +113,9 @@ class Meta:
113
113
def get_node (cls , id , info = None ):
114
114
try :
115
115
model = cls ._meta .model
116
+ identifier = cls ._meta .identifier or "id"
116
117
query = get_query (model , info )
117
- instance = query .filter (model . id == id ).one ()
118
+ instance = query .filter (getattr ( model , identifier ) == id ).one ()
118
119
return cls (instance )
119
120
except NoResultFound :
120
121
return None
You can’t perform that action at this time.
0 commit comments