mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 09:22:43 +03:00
36 lines
1.3 KiB
Python
36 lines
1.3 KiB
Python
import yaml
|
|
from validate import check_query_f, check_query
|
|
from super_classes import DefaultTestSelectQueries
|
|
|
|
|
|
class TestGraphqlIntrospection(DefaultTestSelectQueries):
|
|
|
|
def test_introspection(self, hge_ctx):
|
|
with open(self.dir() + "/introspection.yaml") as c:
|
|
conf = yaml.load(c)
|
|
code, resp = check_query(hge_ctx, conf)
|
|
assert code == 200, resp
|
|
hasArticle = False
|
|
hasArticleAuthorFKRel = False
|
|
hasArticleAuthorManualRel = False
|
|
for t in resp['data']['__schema']['types']:
|
|
if t['name'] == 'article':
|
|
hasArticle = True
|
|
for fld in t['fields']:
|
|
if fld['name'] == 'author_obj_rel_manual':
|
|
hasArticleAuthorManualRel = True
|
|
assert fld['type']['kind'] == 'OBJECT'
|
|
elif fld['name'] == 'author_obj_rel_fk':
|
|
hasArticleAuthorFKRel = True
|
|
assert fld['type']['kind'] == 'NON_NULL'
|
|
assert hasArticle
|
|
assert hasArticleAuthorFKRel
|
|
assert hasArticleAuthorManualRel
|
|
|
|
def test_introspection_user(self, hge_ctx):
|
|
check_query_f(hge_ctx, self.dir() + "/introspection_user_role.yaml")
|
|
|
|
@classmethod
|
|
def dir(cls):
|
|
return "queries/graphql_introspection"
|