Subscriptions-transport-ws: subscribeToMore: GraphQL subscription error (cannot read property 'then' of undefined)

Created on 21 Sep 2017  Â·  14Comments  Â·  Source: apollographql/subscriptions-transport-ws

apollo-client: 1.9.2
apollo-angular: 0.13.1
subscriptions-transport-ws: 0.8.3
angular: 4.4.3

Most helpful comment

Thanks @ianmartorell . I discovered the issue I had, I wasn't matching the arguments in my query to what I had defined in my schema server side. All my libraries are up to speed now and working, the only one I had to downgrade was graphql from 0.13.2 to 0.13.0.

  "dependencies": {
    "apollo-cache-inmemory": "^1.2.6",
    "apollo-client": "^2.3.7",
    "apollo-link-http": "^1.5.4",
    "aws-appsync": "^1.3.3",
    "aws-appsync-react": "^1.1.3",
    "graphql": "0.13.0",  << Might be able to be updated to 0.13.2
    "graphql-tag": "^2.9.2",
    "react": "^16.1.1",
    "react-apollo": "^2.1.9",
    "react-dom": "^16.1.1"
  }

Be sure to match your gql query with what's defined in the schema (in my js client):

export default gql(`
subscription {
  createdEvent {
    name,
    when,
    where,
    description
  }
}`)

And my schema (defined on the server side in aws appsync):

type Subscription {
    createdEvent: Event
        @aws_subscribe(mutations: ["createEvent"])
}

Could probably close this issue.

All 14 comments

try to stay on graphql-js ^0.10.0

I have the same issue, any updates?

I have the same issue, any updates?

I am getting {type: "error", id: "1", payload: {message: "Cannot read property 'then' of undefined"}} error on subscription. What's the best way to debug? Where to look?

I'm Installed "graphql": "^0.10.5" and worked for me

This was fixed with #261

Has the fixed been released? I had this problem. Had to downgrade to graphql 0.10.5

Yeah, upgrading to the latest version resolved it for me at the time.

Hmmm... I must have some version conflicts going on.

"apollo-cache-inmemory": "^1.1.9",
 "apollo-client": "^2.0.4",
 "apollo-link-http": "^1.5.2",
 "apollo-link-ws": "^1.0.7",
 "graphql": "^0.10.5",  //this works, 0.11 got error
 "graphql-subscriptions": "^0.5.8",
 "subscriptions-transport-ws": "^0.9.0",

with graphql 0.11 I was gettting this error message, moving to 0.10.5 seemed to have worked (still testing)

That's not the latest version of subscriptions-transport-ws though! I'm not sure what version introduced the fix, but these are the ones I'm on right now, everything working perfectly:

    "apollo-cache-inmemory": "^1.1.5",
    "apollo-client": "^2.2.0",
    "apollo-link": "^1.0.7",
    "apollo-link-http": "^1.3.2",
    "apollo-link-ws": "^1.0.4",
    "apollo-utilities": "^1.0.4",
    "graphql": "^0.12.3",
    "subscriptions-transport-ws": "^0.9.5"

Also, you don't need graphql-subscriptions on the client.

Make sure to use the same version of graphql on the server as well.

Yeah, I've been playing a delicate version number dance to get this
working. I'll try this particular cocktail and see if it works.

On Fri, Mar 2, 2018 at 1:52 PM, Ian Martorell notifications@github.com
wrote:

That's not the latest version of subscriptions-transport-ws though! I'm
not sure what version introduced the fix, but these are the ones I'm on
right now, everything working perfectly:

"apollo-cache-inmemory": "^1.1.5",
"apollo-client": "^2.2.0",
"apollo-link": "^1.0.7",
"apollo-link-http": "^1.3.2",
"apollo-link-ws": "^1.0.4",
"apollo-utilities": "^1.0.4",
"graphql": "^0.12.3",
"subscriptions-transport-ws": "^0.9.5"

Also, you don't need graphql-subscriptions on the client.

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/apollographql/subscriptions-transport-ws/issues/277#issuecomment-370034142,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAElJuOHR0FH-HP8BHNTyqWsifLc3B6Jks5taaMEgaJpZM4PfLNS
.

This issue is nearly a year old, and I'm getting the following error:

index.js:2177 Unhandled GraphQL subscription error TypeError: Cannot read property 'subscription' of undefined
    at SubscriptionHandshakeLink../node_modules/aws-appsync/lib/link/subscription-handshake-link.js.SubscriptionHandshakeLink.request

Should I still be using version 0.10? Right now I'm using version 11.7 and am somewhat tied to that version since the [email protected] dependency is using that version.

You might have an old version of subscriptions-transport-ws. This issue was caused by graphql expecting a Promise from version ^0.11.0 onwards, and subscriptions-transport-ws not returning one. It was fixed and merged last September in #261, so I would recommend upgrading both of the packages to the latest versions you can, and you should be good. Going back to 0.10 is probably not a good idea, as there's bound to have been countless other bug fixes and improvements since then.

Thanks @ianmartorell . I discovered the issue I had, I wasn't matching the arguments in my query to what I had defined in my schema server side. All my libraries are up to speed now and working, the only one I had to downgrade was graphql from 0.13.2 to 0.13.0.

  "dependencies": {
    "apollo-cache-inmemory": "^1.2.6",
    "apollo-client": "^2.3.7",
    "apollo-link-http": "^1.5.4",
    "aws-appsync": "^1.3.3",
    "aws-appsync-react": "^1.1.3",
    "graphql": "0.13.0",  << Might be able to be updated to 0.13.2
    "graphql-tag": "^2.9.2",
    "react": "^16.1.1",
    "react-apollo": "^2.1.9",
    "react-dom": "^16.1.1"
  }

Be sure to match your gql query with what's defined in the schema (in my js client):

export default gql(`
subscription {
  createdEvent {
    name,
    when,
    where,
    description
  }
}`)

And my schema (defined on the server side in aws appsync):

type Subscription {
    createdEvent: Event
        @aws_subscribe(mutations: ["createEvent"])
}

Could probably close this issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MoonTahoe picture MoonTahoe  Â·  5Comments

altschuler picture altschuler  Â·  4Comments

thebigredgeek picture thebigredgeek  Â·  5Comments

KaiWedekind picture KaiWedekind  Â·  4Comments

ozeals picture ozeals  Â·  3Comments