Skip to content

Commit 1d83cfd

Browse files
committed
Deprecate 'graphql/subscription' and move code to 'execution'
Replicates graphql/graphql-js@588d096
1 parent 44540f3 commit 1d83cfd

16 files changed

+55
-59
lines changed

.coveragerc

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ omit =
88
*/cached_property.py
99
*/character_classes.py
1010
*/is_iterable.py
11+
*/subscription/__init__.py
1112

1213
[report]
1314
exclude_lines =

docs/conf.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@
111111
'language': ['ast', 'directive_locations', 'location',
112112
'source', 'token_kind', 'visitor'],
113113
'pyutils': ['simple_pub_sub', 'frozen_list', 'path'],
114-
'subscription': [],
115114
'type': ['definition', 'directives', 'schema'],
116115
'utilities': ['find_breaking_changes', 'type_info'],
117116
'validation': ['rules', 'validation_context']}
@@ -136,9 +135,9 @@
136135
EnterLeaveVisitor
137136
FormattedSourceLocation
138137
asyncio.events.AbstractEventLoop
138+
graphql.execution.map_async_iterator.MapAsyncIterator
139139
graphql.language.lexer.EscapeSequence
140140
graphql.language.visitor.EnterLeaveVisitor
141-
graphql.subscription.map_async_iterator.MapAsyncIterator
142141
graphql.type.schema.InterfaceImplementations
143142
graphql.validation.validation_context.VariableUsage
144143
graphql.validation.rules.known_argument_names.KnownArgumentNamesOnDirectivesRule

docs/modules/execution.rst

+6
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ Execution
2222
.. autoclass:: FormattedExecutionResult
2323
:no-inherited-members:
2424

25+
.. autofunction:: subscribe
26+
27+
.. autofunction:: create_source_event_stream
28+
29+
.. autoclass:: MapAsyncIterator
30+
2531
.. autoclass:: Middleware
2632

2733
.. autoclass:: MiddlewareManager

docs/modules/graphql.rst

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ Sub-Packages
2727
execution
2828
language
2929
pyutils
30-
subscription
3130
type
3231
utilities
3332
validation

docs/modules/subscription.rst

-17
This file was deleted.

docs/usage/other.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
Subscriptions
22
-------------
33

4-
.. currentmodule:: graphql.subscription
4+
.. currentmodule:: graphql.execution
55

66
Sometimes you need to not only query data from a server, but you also want to push data
77
from the server to the client. GraphQL-core 3 has you also covered here, because it
88
implements the "Subscribe" algorithm described in the GraphQL spec. To execute a GraphQL
99
subscription, you must use the :func:`subscribe` method from the
10-
:mod:`graphql.subscription` module. Instead of a single
10+
:mod:`graphql.execution` package. Instead of a single
1111
:class:`~graphql.execution.ExecutionResult`, this function returns an asynchronous
1212
iterator yielding a stream of those, unless there was an immediate error.
1313
Of course you will then also need to maintain a persistent channel to the client

src/graphql/__init__.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
- :mod:`graphql.error`: Creating and formatting GraphQL errors.
3535
- :mod:`graphql.utilities`:
3636
Common useful computations upon the GraphQL language and type objects.
37-
- :mod:`graphql.subscription`: Subscribe to data updates.
3837
"""
3938

4039
# The GraphQL-core 3 and GraphQL.js version info.
@@ -286,14 +285,15 @@
286285
ExecutionContext,
287286
ExecutionResult,
288287
FormattedExecutionResult,
288+
# Subscription
289+
subscribe,
290+
create_source_event_stream,
291+
MapAsyncIterator,
289292
# Middleware
290293
Middleware,
291294
MiddlewareManager,
292295
)
293296

294-
from .subscription import subscribe, create_source_event_stream, MapAsyncIterator
295-
296-
297297
# Validate GraphQL queries.
298298
from .validation import (
299299
validate,

src/graphql/execution/__init__.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,22 @@
1414
FormattedExecutionResult,
1515
Middleware,
1616
)
17-
17+
from .map_async_iterator import MapAsyncIterator
18+
from .subscribe import subscribe, create_source_event_stream
1819
from .middleware import MiddlewareManager
19-
2020
from .values import get_directive_values
2121

2222
__all__ = [
23+
"create_source_event_stream",
2324
"execute",
2425
"execute_sync",
2526
"default_field_resolver",
2627
"default_type_resolver",
28+
"subscribe",
2729
"ExecutionContext",
2830
"ExecutionResult",
2931
"FormattedExecutionResult",
32+
"MapAsyncIterator",
3033
"Middleware",
3134
"MiddlewareManager",
3235
"get_directive_values",

src/graphql/subscription/__init__.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,15 @@
22
33
The :mod:`graphql.subscription` package is responsible for subscribing to updates
44
on specific data.
5+
6+
.. deprecated:: 3.3
7+
This package has been deprecated with its exported functions integrated into the
8+
:mod:`graphql.execution` package, to better conform with the terminology of the
9+
GraphQL specification. For backwards compatibility, the :mod:`graphql.subscription`
10+
package currently re-exports the moved functions from the :mod:`graphql.execution`
11+
package. In v3.3, the :mod:`graphql.subscription` package will be dropped entirely.
512
"""
613

7-
from .subscribe import subscribe, create_source_event_stream
8-
from .map_async_iterator import MapAsyncIterator
14+
from ..execution import subscribe, create_source_event_stream, MapAsyncIterator
915

1016
__all__ = ["subscribe", "create_source_event_stream", "MapAsyncIterator"]

tests/subscription/test_map_async_iterator.py renamed to tests/execution/test_map_async_iterator.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
from pytest import mark, raises
55

6-
from graphql.subscription.map_async_iterator import MapAsyncIterator
6+
from graphql.execution import MapAsyncIterator
77

88

99
try: # pragma: no cover

tests/subscription/test_subscribe.py renamed to tests/execution/test_subscribe.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
GraphQLSchema,
1717
GraphQLString,
1818
)
19-
from graphql.subscription import create_source_event_stream, subscribe, MapAsyncIterator
19+
from graphql.execution import create_source_event_stream, subscribe, MapAsyncIterator
2020

2121
try:
2222
anext

tests/subscription/__init__.py

-1
This file was deleted.

tests/test_user_registry.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
)
3737

3838
from graphql.pyutils import SimplePubSub, SimplePubSubIterator
39-
from graphql.subscription.map_async_iterator import MapAsyncIterator
39+
from graphql.execution.map_async_iterator import MapAsyncIterator
4040

4141

4242
class User(NamedTuple):

tests/utilities/test_extend_schema.py

+25-25
Original file line numberDiff line numberDiff line change
@@ -139,15 +139,15 @@ def extends_objects_by_adding_new_fields():
139139
extended_schema,
140140
dedent(
141141
'''
142-
type SomeObject implements AnotherInterface & SomeInterface {
143-
self: SomeObject
144-
tree: [SomeObject]!
145-
"""Old field description."""
146-
oldField: String
147-
"""New field description."""
148-
newField(arg: Boolean): String
149-
}
150-
'''
142+
type SomeObject implements AnotherInterface & SomeInterface {
143+
self: SomeObject
144+
tree: [SomeObject]!
145+
"""Old field description."""
146+
oldField: String
147+
"""New field description."""
148+
newField(arg: Boolean): String
149+
}
150+
'''
151151
),
152152
)
153153

@@ -226,13 +226,13 @@ def extends_enums_by_adding_new_values():
226226
extended_schema,
227227
dedent(
228228
'''
229-
enum SomeEnum {
230-
"""Old value description."""
231-
OLD_VALUE
232-
"""New value description."""
233-
NEW_VALUE
234-
}
235-
'''
229+
enum SomeEnum {
230+
"""Old value description."""
231+
OLD_VALUE
232+
"""New value description."""
233+
NEW_VALUE
234+
}
235+
'''
236236
),
237237
)
238238

@@ -263,8 +263,8 @@ def extends_unions_by_adding_new_types():
263263
extended_schema,
264264
dedent(
265265
"""
266-
union SomeUnion = Foo | Biz | Bar
267-
"""
266+
union SomeUnion = Foo | Biz | Bar
267+
"""
268268
),
269269
)
270270

@@ -318,13 +318,13 @@ def extends_inputs_by_adding_new_fields():
318318
extended_schema,
319319
dedent(
320320
'''
321-
input SomeInput {
322-
"""Old field description."""
323-
oldField: String
324-
"""New field description."""
325-
newField: String
326-
}
327-
'''
321+
input SomeInput {
322+
"""Old field description."""
323+
oldField: String
324+
"""New field description."""
325+
newField: String
326+
}
327+
'''
328328
),
329329
)
330330

0 commit comments

Comments
 (0)