Merge pull request #187 from graphql-python/register-interface-failure-fix

Register interface failure fix
This commit is contained in:
Syrus Akbary 2016-05-28 16:52:56 -07:00
commit e5357ccc84
2 changed files with 16 additions and 0 deletions

View File

@ -77,6 +77,7 @@ class Schema(object):
self,
query=self.T(self.query),
mutation=self.T(self.mutation),
types=[self.T(_type) for _type in list(self._types_names.values())],
subscription=self.T(self.subscription))
def register(self, object_type, force=False):

View File

@ -132,6 +132,21 @@ def test_schema_register():
assert schema.get_type('MyType') == MyType
def test_schema_register_interfaces():
class Query(ObjectType):
f = Field(Character)
def resolve_f(self, args, info):
return Human()
schema = Schema(query=Query)
schema.register(Human)
result = schema.execute('{ f { name } }')
assert not result.errors
def test_schema_register_no_query_type():
schema = Schema(name='My own schema')