Skip to content

Commit

Permalink
[v0.3.0] Add support for subscription type definitions in the Schem…
Browse files Browse the repository at this point in the history
…a & bump graphql to v0.4.9.
  • Loading branch information
jhgg committed Nov 17, 2015
1 parent 951e014 commit 70e8b95
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 7 deletions.
5 changes: 3 additions & 2 deletions epoxy/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,11 +313,12 @@ def _add_impl_to_interfaces(self):

interface._impls.append(type)

def Schema(self, query, mutation=None):
def Schema(self, query, mutation=None, subscription=None):
query = self[query]()
mutation = self[mutation]()
subscription = self[subscription]()
self._add_impl_to_interfaces()
return GraphQLSchema(query=query, mutation=mutation)
return GraphQLSchema(query=query, mutation=mutation, subscription=subscription)

def Mixin(self, mixin_cls, *args, **kwargs):
mixin = mixin_cls(self, *args, **kwargs)
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from setuptools import setup, find_packages
import sys

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

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

setup(
name='graphql-epoxy',
version='0.2.1',
version='0.3.0',
description='GraphQL implementation for Python',
url='https://github.com/graphql-python/graphql-core',
download_url='https://github.com/graphql-python/graphql-core/releases',
Expand Down
29 changes: 29 additions & 0 deletions tests/test_subscription.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from graphql.core import graphql

from epoxy.registry import TypeRegistry


def test_can_define_and_execute_subscription():
R = TypeRegistry()

class Query(R.ObjectType):
a = R.Int

class Subscription(R.ObjectType):
subscribe_to_foo = R.Boolean(args={'id': R.Int})

def resolve_subscribe_to_foo(self, obj, args, info):
return args.get('id') == 1

Schema = R.Schema(R.Query, subscription=R.Subscription)

response = graphql(Schema, '''
subscription {
subscribeToFoo(id: 1)
}
''')

assert not response.errors
assert response.data == {
'subscribeToFoo': True
}
2 changes: 0 additions & 2 deletions tests/test_true.py

This file was deleted.

2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ whitelist_externals =
dir
deps =
pytest>=2.7.2
graphql-core>=0.4.7b1
graphql-core>=0.4.9
six>=1.10.0
pytest-cov
py{py,27,33}: enum34
Expand Down

0 comments on commit 70e8b95

Please sign in to comment.