Subscription field must return Async Iterable. Received: undefined

prisma

#1

Does anyone know what this means?

Subscription field must return Async Iterable. Received: undefined

image


#2

It means that somewhere, some piece of code expected an object to be an async iterable, but it was undefined instead :slight_smile:

To me, it’s not clear where exactly that piece of code is actually running - it might be the GraphQL Playground, it might be your server code, or something entirely different.

Can you share a bit more context how you ended up with this error message? That would be tremendously helpful in understanding what’s going on :raised_hands:


#3

Hey @nilan I am getting this error as well and I think it’s because I haven’t added the resolver for the subscription.

I can’t seem to find anything in the prisma docs but I have this in the schema.graphql

type Subscription {
  truck(where: TruckSubscriptionWhereInput!): TruckSubscriptionPayload
}

When I go to the playground and try to execute the subscription I get the OP error message.

What do I need to do to resolve this? It works if I access the database playground directly.


#4

Hey @johhansantana, interesting!

That sounds like the likely cause, have you tried adding the subscription resolver, like in this example? :slight_smile:

@jingle, might that also be the problem you’re facing?


#5

yes, that worked perfectly. I should look more often in those examples!


#6

Great @johhansantana, glad that helped!

If you have any feedback for improving the examples feel free to share it!
Also, PRs are highly welcome if you see something to improve or want to provide a small example yourself.

Cheers :raised_hands:


#7

Hi,
Could you tell me how to fix this error?
{
“error”: {
“message”: “Subscription field must return Async Iterable. Received: undefined”
}
}

   //schema.graphgl    
                type Subscription {
                      course(where: CourseSubscriptionWhereInput): CourseSubscriptionPayload
                    }


//resolver
  const {forwardTo} = require('prisma-binding);
    Subscription: {
        course: forwardTo('db')
      }

#8

What is the version of prisma-binding?

Sorry, there’s a mistake in your code, you forgot to add subscribe key:

//resolver
const {forwardTo} = require('prisma-binding);

const Subscription = {
    course: {
        subscribe: forwardTo('db)
    }
}

#9

I tried it. Subscription is not working. When I create new record prisma server stops the subscription and listen for the new data.
Any idea or suggestion please?


#10

Do you have the code somewhere? Do you have the link to graphql playground? Thanks!


#11


Please checkout the subscription branch
git checkout subscription
Please let me know If I need to update anything.


#12

I got exactly the same problem. I forgot to add the resolver to the subscription.