Skip to content
This repository was archived by the owner on Sep 6, 2022. It is now read-only.

Commit b8997ec

Browse files
committed
Fixed NdbKeyField.internal_type
1 parent d4ba0b9 commit b8997ec

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

graphene_gae/ndb/fields.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def internal_type(self, schema):
126126
"You can either register the type manually "
127127
"using @schema.register. "
128128
"Or disable the field in %s" % (
129-
self.model,
129+
self.kind,
130130
self.parent,
131131
)
132132
)

tests/_ndb/test_types.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import graphene
44

5-
from graphene_gae import NdbObjectType
5+
from graphene_gae import NdbObjectType, NdbKeyField
66
from tests.models import Tag, Comment, Article, Address, Author, PhoneNumber
77

88
__author__ = 'ekampf'
@@ -82,6 +82,27 @@ class Meta:
8282

8383
assert 'not an NDB model' in str(context.exception.message)
8484

85+
def testNdbObjectType_keyProperty_kindDoesntExist_raisesException(self):
86+
with self.assertRaises(Exception) as context:
87+
class ArticleType(NdbObjectType):
88+
class Meta:
89+
model = Article
90+
only_fields = ('prop',)
91+
92+
prop = NdbKeyField('foo', 'bar')
93+
94+
class QueryType(graphene.ObjectType):
95+
articles = graphene.List(ArticleType)
96+
97+
@graphene.resolve_only_args
98+
def resolve_articles(self):
99+
return Article.query()
100+
101+
schema = graphene.Schema(query=QueryType)
102+
result = schema.execute('query test { articles { prop } }')
103+
104+
self.assertIn("Model 'bar' is not accessible by the schema.", str(context.exception.message))
105+
85106
def testQuery_excludedField(self):
86107
Article(headline="h1", summary="s1").put()
87108

0 commit comments

Comments
 (0)