Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[object Object] Result when doing pubsub.publish #96

Closed
ralphchristianeclipse opened this issue Aug 3, 2017 · 1 comment
Closed

[object Object] Result when doing pubsub.publish #96

ralphchristianeclipse opened this issue Aug 3, 2017 · 1 comment

Comments

@ralphchristianeclipse
Copy link

The problem is when publishing a value it will return null on the subscribe method

export const subscriptions = model => ({
    [model]: {
        resolve(payload) {
            console.log({...payload[model]})
            return {...payload[model]}  
        },
        subscribe: withFilter(() => pubsub.asyncIterator(
            ['CREATED','UPDATED', 'DELETED']
            .map(mutation => `${model.toUpperCase()}_${mutation}`)),
            (payload,variables) => {
                return payload.id === variables.id
            })
    }
})

And publishing it like this

    [`update${model}`]: async(_, { id, ...args }, { models }, info) => {
        let result = await models[model].findById(id)
        await result.update(args)
        pubsub.publish(`${model.toUpperCase()}_UPDATED`, {
            [model]: args
        })
        
        return result
    },

this is what i get received from the Subscription resolve

[nodemon] starting `babel-node src`
Server started at 0.0.0.0:8080
express deprecated req.host: Use req.hostname instead src/server.js:97:88
{ name: 'testerssas',
  description: 'test',
  slug: 'testerssas',
  fee: 0 }
POST /graphql 200 59.101 ms - -

and getting this error

image

Noticed that [object Object] is an error

@ralphchristianeclipse
Copy link
Author

ralphchristianeclipse commented Aug 3, 2017

I think the problem is not returning an id on the publish but doing rather sending the args

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

No branches or pull requests

1 participant