Skip to content

Commit 70e8b95

Browse files
committed
[v0.3.0] Add support for subscription type definitions in the Schema & bump graphql to v0.4.9.
1 parent 951e014 commit 70e8b95

File tree

5 files changed

+35
-7
lines changed

5 files changed

+35
-7
lines changed

Diff for: epoxy/registry.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -313,11 +313,12 @@ def _add_impl_to_interfaces(self):
313313

314314
interface._impls.append(type)
315315

316-
def Schema(self, query, mutation=None):
316+
def Schema(self, query, mutation=None, subscription=None):
317317
query = self[query]()
318318
mutation = self[mutation]()
319+
subscription = self[subscription]()
319320
self._add_impl_to_interfaces()
320-
return GraphQLSchema(query=query, mutation=mutation)
321+
return GraphQLSchema(query=query, mutation=mutation, subscription=subscription)
321322

322323
def Mixin(self, mixin_cls, *args, **kwargs):
323324
mixin = mixin_cls(self, *args, **kwargs)

Diff for: setup.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from setuptools import setup, find_packages
22
import sys
33

4-
required_packages = ['graphql-core>=0.4.7b1']
4+
required_packages = ['graphql-core>=0.4.9']
55

66
if sys.version_info <= (2, 7, 0):
77
required_packages.append('enum34>=1.0.4')
@@ -11,7 +11,7 @@
1111

1212
setup(
1313
name='graphql-epoxy',
14-
version='0.2.1',
14+
version='0.3.0',
1515
description='GraphQL implementation for Python',
1616
url='https://github.com/graphql-python/graphql-core',
1717
download_url='https://github.com/graphql-python/graphql-core/releases',

Diff for: tests/test_subscription.py

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from graphql.core import graphql
2+
3+
from epoxy.registry import TypeRegistry
4+
5+
6+
def test_can_define_and_execute_subscription():
7+
R = TypeRegistry()
8+
9+
class Query(R.ObjectType):
10+
a = R.Int
11+
12+
class Subscription(R.ObjectType):
13+
subscribe_to_foo = R.Boolean(args={'id': R.Int})
14+
15+
def resolve_subscribe_to_foo(self, obj, args, info):
16+
return args.get('id') == 1
17+
18+
Schema = R.Schema(R.Query, subscription=R.Subscription)
19+
20+
response = graphql(Schema, '''
21+
subscription {
22+
subscribeToFoo(id: 1)
23+
}
24+
''')
25+
26+
assert not response.errors
27+
assert response.data == {
28+
'subscribeToFoo': True
29+
}

Diff for: tests/test_true.py

-2
This file was deleted.

Diff for: tox.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ whitelist_externals =
77
dir
88
deps =
99
pytest>=2.7.2
10-
graphql-core>=0.4.7b1
10+
graphql-core>=0.4.9
1111
six>=1.10.0
1212
pytest-cov
1313
py{py,27,33}: enum34

0 commit comments

Comments
 (0)