Amplify-js: No pubsub module applied for subscription.

Created on 1 Jul 2019  路  5Comments  路  Source: aws-amplify/amplify-js

I encountered a problem as follows issue
https://github.com/aws-amplify/amplify-js/issues/3484

And I tried to change aws-amplify import statement following this solution

I solved it but I got another error as follows

Error: No pubsub module applied for subscription
    at APIClass._graphqlSubscribe (API.js?0f51:615)
    at APIClass.graphql (API.js?0f51:468)
    at VueComponent.created (Home.vue?13b0:77)
    at invokeWithErrorHandling (vue.runtime.esm.js?2b0e:1854)
    at callHook (vue.runtime.esm.js?2b0e:4213)
    at VueComponent.Vue._init (vue.runtime.esm.js?2b0e:5002)
    at new VueComponent (vue.runtime.esm.js?2b0e:5148)
    at createComponentInstanceForVnode (vue.runtime.esm.js?2b0e:3283)
    at init (vue.runtime.esm.js?2b0e:3114)
    at createComponent (vue.runtime.esm.js?2b0e:5972)

I don't use PubSub in .vue file.
Perhaps, it was triggered by limiting import.
What should I do ?

API pending-close-response-required

Most helpful comment

I have the same issue, with the api category it uses pubsub for subscriptions, but amplify doesn't generate any config for it?

All 5 comments

Hey @yukitaka13-1110,

Are you using the API category for graphql subscriptions? Also, can you post which versions of amplify modules you are using.

@jordanranz
Sorry for lating response.

My package.json is as follows

  "dependencies": {
    "@aws-amplify/cli": "^1.7.2",
    "@aws-amplify/ui": "^1.0.20",
    "@types/graphql": "^14.2.0",
    "@types/zen-observable": "^0.8.0",
    "aws-amplify": "^1.1.29",
    "aws-amplify-vue": "^0.2.12",
    "aws-sdk": "^2.479.0",
    "core-js": "^2.6.5",
    "register-service-worker": "^1.6.2",
    "rxjs-compat": "^6.5.2",
    "vue": "^2.6.10",
    "vue-class-component": "^7.0.2",
    "vue-property-decorator": "^8.1.0",
    "vue-router": "^3.0.3",
    "vuetify": "^1.5.5",
    "vuex": "^3.0.1"
  },
  "devDependencies": {
    "@types/jest": "^23.1.4",
    "@types/node": "^12.0.3",
    "@vue/cli-plugin-babel": "^3.8.0",
    "@vue/cli-plugin-e2e-cypress": "^3.8.0",
    "@vue/cli-plugin-eslint": "^3.8.0",
    "@vue/cli-plugin-pwa": "^3.8.0",
    "@vue/cli-plugin-typescript": "^3.8.0",
    "@vue/cli-plugin-unit-jest": "^3.8.0",
    "@vue/cli-service": "^3.8.0",
    "@vue/eslint-config-standard": "^4.0.0",
    "@vue/eslint-config-typescript": "^4.0.0",
    "@vue/test-utils": "1.0.0-beta.29",
    "babel-core": "7.0.0-bridge.0",
    "babel-eslint": "^10.0.1",
    "eslint": "^5.16.0",
    "eslint-plugin-vue": "^5.0.0",
    "lint-staged": "^8.1.5",
    "sass": "^1.18.0",
    "sass-loader": "^7.1.0",
    "stylus": "^0.54.5",
    "stylus-loader": "^3.0.1",
    "ts-jest": "^23.0.0",
    "typescript": "3.4.5",
    "vue-cli-plugin-pug": "^1.0.7",
    "vue-cli-plugin-vuetify": "^0.5.0",
    "vue-template-compiler": "^2.6.10",
    "vuetify-loader": "^1.0.5"
  },

My import

import API, { graphqlOperation } from '@aws-amplify/api'
import Auth from '@aws-amplify/auth'
import Storage from '@aws-amplify/storage'
// @ts-ignore
import { S3Image } from 'aws-amplify-vue/src/components/storage'
import router from '@/router'
import * as APITypes from '../API'
import { createXXX, deleteXXX, updateXXX } from '../graphql/mutations'
import { GraphQLResult } from '@aws-amplify/api/lib/types'
import { listXXX, getXXX } from '../graphql/queries'
import { onCreateXXX, onDeleteXXX, onUpdateXXX } from '../graphql/subscriptions'
import Vue, { PropType } from 'vue'
import Observable from 'zen-observable'

GraphQL subscription

    const createSubscription = API.graphql(graphqlOperation(onCreateXXX))
    if (createSubscription instanceof Observable) {
      createSubscription.subscribe({
        next: ({
          value: {
            data: { onCreateXXX: createItem }
          }
        }: {
          value: {
            data: { onCreateXXX: APITypes.CreateXXXInput }
          }
        }) => {
          console.log(createItem)
          this.XXXXX.push(createItem)
        }
      })
    }

I have the same issue, with the api category it uses pubsub for subscriptions, but amplify doesn't generate any config for it?

@yukitaka13-1110 Could you confirm if you still have this issue.

This issue has been automatically closed because of inactivity. Please open a new issue if are still encountering problems.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

guanzo picture guanzo  路  3Comments

leantide picture leantide  路  3Comments

romainquellec picture romainquellec  路  3Comments

shinnapatthesix picture shinnapatthesix  路  3Comments

cosmosof picture cosmosof  路  3Comments