Skip to content

Async schema does not return observable #452

Closed
@japrogramer

Description

@japrogramer

Here i am trying to run an async schema

            # stream is an rx.Subject
            result = graphql(schema,
                    payload['query'],
                    variable_values=payload['variables'],
                    root_value=stream.share(),
                    allow_subscriptions=True,
                    executor=AsyncioExecutor(loop=asyncio.get_event_loop()),
                    **{'context_value': message})

Here is the schema

class ProductSubscritption(object):

    """test"""
    sub_product = graphene.Field(
        ProductType,
        description='subscribe to updated product',
        product=graphene.ID())

    async def resolve_sub_product(self, info, **input):
        def next(message, info, **input):
            # here the message comes from the stream but the info and **input come frome
            # subscribing to the next method to the stream
            __import__('pdb').set_trace()
            inst = relay.Node.get_node_from_global_id(info, input.get('product'))
            return inst

        await make_sub(info, input.get('product'))
        name = ProductType._meta.model.__class__.__name__

        stream = info.root_value
        obv = stream.map(lambda message: next(message, info, **input))
        register = info.context['register']
        if register:
            __import__('pdb').set_trace()
            register(obv)
        return obv

And here is the value of result

(Pdb) result
<graphql.execution.base.ExecutionResult object at 0x7f1f08114168>
(Pdb) result.errors
[RuntimeError('This event loop is already running',)]
(Pdb) result.data
(Pdb)

I know that despite the error in result the schema continues in the background because of the brake points I have set.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions