Skip to content

Commit ea71ad5

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

File tree

3 files changed

+56868
-2
lines changed

3 files changed

+56868
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from graphql import build_client_schema, GraphQLSchema
2+
3+
# noinspection PyUnresolvedReferences
4+
from ..fixtures import big_schema_introspection_result # noqa: F401
5+
6+
7+
def test_build_schema_from_introspection(
8+
benchmark, big_schema_introspection_result # noqa: F811
9+
):
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

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

55
from pytest import fixture # type: ignore
66

7-
__all__ = ["kitchen_sink_query", "kitchen_sink_sdl", "big_schema_sdl"]
7+
__all__ = [
8+
"kitchen_sink_query",
9+
"kitchen_sink_sdl",
10+
"big_schema_sdl",
11+
"big_schema_introspection_result",
12+
]
813

914

1015
def read_graphql(name):
1116
path = join(dirname(__file__), name + ".graphql")
1217
return open(path, encoding="utf-8").read()
1318

1419

20+
def read_json(name):
21+
path = join(dirname(__file__), name + ".json")
22+
return json.load(open(path, encoding="utf-8"))
23+
24+
1525
@fixture(scope="module")
1626
def kitchen_sink_query():
1727
return read_graphql("kitchen_sink")
@@ -25,3 +35,8 @@ def kitchen_sink_sdl():
2535
@fixture(scope="module")
2636
def big_schema_sdl():
2737
return read_graphql("github_schema")
38+
39+
40+
@fixture(scope="module")
41+
def big_schema_introspection_result():
42+
return read_json("github_schema")

0 commit comments

Comments
 (0)