File tree Expand file tree Collapse file tree 2 files changed +56
-0
lines changed Expand file tree Collapse file tree 2 files changed +56
-0
lines changed Original file line number Diff line number Diff line change @@ -621,6 +621,14 @@ def print_schema(schema: BaseSchema) -> str:
621
621
if (printed_directive := print_directive (directive , schema = schema )) is not None
622
622
]
623
623
624
+ if schema .config .enable_experimental_incremental_execution :
625
+ directives .append (
626
+ "directive @defer(if: Boolean, label: String) on FRAGMENT_SPREAD | INLINE_FRAGMENT"
627
+ )
628
+ directives .append (
629
+ "directive @stream(if: Boolean, label: String, initialCount: Int = 0) on FIELD"
630
+ )
631
+
624
632
def _name_getter (type_ : Any ) -> str :
625
633
if hasattr (type_ , "name" ):
626
634
return type_ .name
Original file line number Diff line number Diff line change
1
+ from __future__ import annotations
2
+
3
+ import textwrap
4
+
5
+ import strawberry
6
+ from strawberry .schema .config import StrawberryConfig
7
+ from tests .conftest import skip_if_gql_32
8
+
9
+ pytestmark = skip_if_gql_32 ("GraphQL 3.3.0 is required for incremental execution" )
10
+
11
+
12
+ @strawberry .type
13
+ class Query :
14
+ hello : str
15
+
16
+
17
+ def test_does_not_print_defer_and_stream_directives_when_experimental_execution_is_disabled ():
18
+ schema = strawberry .Schema (
19
+ query = Query ,
20
+ config = StrawberryConfig (enable_experimental_incremental_execution = False ),
21
+ )
22
+
23
+ expected_type = """
24
+ type Query {
25
+ hello: String!
26
+ }
27
+ """
28
+
29
+ assert str (schema ) == textwrap .dedent (expected_type ).strip ()
30
+
31
+
32
+ def test_prints_defer_and_stream_directives_when_experimental_execution_is_enabled ():
33
+ schema = strawberry .Schema (
34
+ query = Query ,
35
+ config = StrawberryConfig (enable_experimental_incremental_execution = True ),
36
+ )
37
+
38
+ expected_type = """
39
+ directive @defer(if: Boolean, label: String) on FRAGMENT_SPREAD | INLINE_FRAGMENT
40
+
41
+ directive @stream(if: Boolean, label: String, initialCount: Int = 0) on FIELD
42
+
43
+ type Query {
44
+ hello: String!
45
+ }
46
+ """
47
+
48
+ assert str (schema ) == textwrap .dedent (expected_type ).strip ()
You can’t perform that action at this time.
0 commit comments