gramps-graphql / gramps--legacy

The core data source combination engine of GrAMPS.

Home Page:https://gramps.js.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot setup Subscription resolvers in top level resolvers map

grxy opened this issue · comments

commented

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.

commented

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

commented

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

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

@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.