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

encountered issues with asyncIterator, found suggestions for and successfully implemented asyncIterableIterator #3985

Open
wants to merge 5 commits into
base: source
Choose a base branch
from

Conversation

jayhcrawford
Copy link
Contributor

@jayhcrawford jayhcrawford commented Feb 6, 2025

You will find that the docs reference this method (asyncIterableIterator) under the AsyncIterator section, and cease referencing AsyncIterator:
https://www.apollographql.com/tutorials/federated-subscriptions-typescript/06-subscription-resolver#asynciterator

When I use AsyncIterator and the course content copied directly, Apollo Server gives this error:

{
  "errors": [
    {
      "message": "pubsub.asyncIterator is not a function",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "newBook"
      ]
   }
  ]
}

by changing the method to asyncIterableIterator per suggestion from this Stack Overflow answer:
https://stackoverflow.com/questions/79302579/pubsub-error-property-asynciterator-does-not-exist-on-type-pubsubrecordstr
and following the structure described in the docs:
https://www.apollographql.com/tutorials/federated-subscriptions-typescript/06-subscription-resolver#asynciterator

Apollo Server successfully opened a subscription connection and showed subscriptions working as expected.

It looks like AsyncIterator is implemented, albeit differently here:
https://www.npmjs.com/package/graphql-subscriptions
but these docs also make reference to asyncIterableIterator, and its usage looks more similar to the course's suggested usage of AsyncIterator.

@vejol vejol added the part 8 label Feb 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants