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

File tree

16 files changed

+55
-59
lines changed

16 files changed

+55
-59
lines changed

.coveragerc

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 2 deletions
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

Lines changed: 6 additions & 0 deletions
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 0 additions & 17 deletions
This file was deleted.

docs/usage/other.rst

Lines changed: 2 additions & 2 deletions
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

Lines changed: 4 additions & 4 deletions
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

Lines changed: 5 additions & 2 deletions
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",
File renamed without changes.

0 commit comments

Comments
 (0)