Skip to content
This repository has been archived by the owner on Sep 11, 2019. It is now read-only.

Cannot setup Subscription resolvers in top level resolvers map #58

Closed
grxy opened this issue Dec 21, 2017 · 4 comments · Fixed by #59
Closed

Cannot setup Subscription resolvers in top level resolvers map #58

grxy opened this issue Dec 21, 2017 · 4 comments · Fixed by #59

Comments

@grxy
Copy link

grxy commented Dec 21, 2017

I have the following source code

import pubsub from 'services/pubsub'

const identity = i => i

const FailingSubscriptionDataSource = {
    namespace: 'Subscription',
    resolvers: {
        Subscription: {
            test: {
                resolve: identity,
                subscribe: () => pubsub.asyncIterator('test')
            },
        }
    },
    typeDefs: `
        type Query {
            test: Float
        }

        type Subscription {
            test: Float
        }
    `
}

const WorkingSubscriptionDataSource = {
    namespace: 'Subscription',
    stitching: {
        resolvers: (mergeInfo) => ({
            Subscription: {
                test: {
                    resolve: identity,
                    subscribe: () => pubsub.asyncIterator('test')
                },
            }
        })
    },
    typeDefs: `
        type Query {
            test: Float
        }

        type Subscription {
            test: Float
        }
    `
}

setInterval(() => {
    const value = Math.random()

    pubsub.publish('test', value)
}, 250)

I am able to get this subscription working using the stitching method, but when I set the top level resolvers, I get this error in mapResolvers: Error: Expected Function for test resolver but received object Any ideas on how to support subscription resolvers at the top level of a data source.

I'm on @gramps/gramps beta 9.

jlengstorf pushed a commit that referenced this issue Dec 21, 2017
* do not map Subscription resolvers
* reduce cognitive complexity

close #58
@grxy
Copy link
Author

grxy commented Dec 21, 2017

@jlengstorf What's the publish plan for things like this?

@grxy
Copy link
Author

grxy commented Dec 21, 2017

@jlengstorf Asking specifically because I need a version that requires graphql-tools@2.14.1, which I see as required in master.

@jlengstorf
Copy link
Member

@grxy Did this not auto-publish? Goddammit. Let me manually release. 😖

@jlengstorf
Copy link
Member

@grxy It's building now: https://travis-ci.org/gramps-graphql/gramps/builds/319872752 — if you don't see a new release in the next 10 minutes or so, holler at me.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants