Skip to content

Commit 5559eca

Browse files
committed
Port building Schema from introspection benchmark
From src/utilities/__tests__/buildClientSchema-benchmark.js
1 parent abe48f3 commit 5559eca

File tree

3 files changed

+56862
-1
lines changed

3 files changed

+56862
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from graphql import parse, build_ast_schema, build_client_schema, GraphQLSchema
2+
3+
# noinspection PyUnresolvedReferences
4+
from ..fixtures import big_schema_introspection_result # noqa: F401
5+
6+
7+
def test_building_ast_from_introspection(
8+
benchmark, big_schema_introspection_result
9+
): # noqa: F811
10+
schema: GraphQLSchema = benchmark(
11+
lambda: build_client_schema(
12+
big_schema_introspection_result["data"], assume_valid=True
13+
)
14+
)
15+
assert schema.query_type is not None

tests/fixtures/__init__.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""Fixtures for graphql tests"""
2-
2+
import json
33
from os.path import dirname, join
44

55
from pytest import fixture # type: ignore
@@ -12,6 +12,11 @@ def read_graphql(name):
1212
return open(path, encoding="utf-8").read()
1313

1414

15+
def read_json(name):
16+
path = join(dirname(__file__), name + ".json")
17+
return json.loads(open(path, encoding="utf-8").read())
18+
19+
1520
@fixture(scope="module")
1621
def kitchen_sink_query():
1722
return read_graphql("kitchen_sink")
@@ -25,3 +30,8 @@ def kitchen_sink_sdl():
2530
@fixture(scope="module")
2631
def big_schema_sdl():
2732
return read_graphql("github_schema")
33+
34+
35+
@fixture(scope="module")
36+
def big_schema_introspection_result():
37+
return read_json("github_schema")

0 commit comments

Comments
 (0)