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

Patched: Issue #110 #163

Merged

Conversation

kamerontanseli
Copy link
Contributor

@kamerontanseli kamerontanseli commented Jan 4, 2019

Fixes #110

Error when full websockets server is in use:

{
  "errors": [
    {
      "message": "n(...).map is not a function",
      "locations": [
        "TypeError: n(...).map is not a function\n    at e.request (chrome-extension://jdkknkkbebbapilgoeccciglkfbmbnfm/dist/backend.js:1:38659)\n    at chrome-extension://jdkknkkbebbapilgoeccciglkfbmbnfm/dist/backend.js:1:3681\n    at e.request (chrome-extension://jdkknkkbebbapilgoeccciglkfbmbnfm/dist/backend.js:1:38421)\n    at chrome-extension://jdkknkkbebbapilgoeccciglkfbmbnfm/dist/backend.js:1:3681\n    at chrome-extension://jdkknkkbebbapilgoeccciglkfbmbnfm/dist/backend.js:1:38085\n    at new s (chrome-extension://jdkknkkbebbapilgoeccciglkfbmbnfm/dist/backend.js:1:4855)\n    at l.subscribe (chrome-extension://jdkknkkbebbapilgoeccciglkfbmbnfm/dist/backend.js:1:6185)\n    at n.<anonymous> (chrome-extension://jdkknkkbebbapilgoeccciglkfbmbnfm/dist/backend.js:1:38914)\n    at n.t.emit (chrome-extension://jdkknkkbebbapilgoeccciglkfbmbnfm/dist/backend.js:1:52786)\n    at chrome-extension://jdkknkkbebbapilgoeccciglkfbmbnfm/dist/backend.js:1:19519"
      ]
    }
  ]
}

Patch forward(operation) was returning null which caused .map() to fail:

const schemaLink = () =>
  new ApolloLink((operation, forward) => {
    return new Observable(observer => { // wrap result in an observable
      const ob = forward(operation); 
      if (ob) { // check if forward returns not null
        return forward(operation).subscribe(result => {
          let { schemas = [] } = operation.getContext();
          try {
            result.extensions = Object.assign({}, result.extensions, {
              schemas: schemas.concat([apolloClientSchema]),
            });
          } catch (error) {
            console.error(error);
          }
          return observer.next(result); // return the result
        });
      }
      return () => {
        if (ob) ob.unsubscribe();
      };
    });
  });

@apollo-cla
Copy link

@kamerontanseli: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Meteor Contributor Agreement here: https://contribute.meteor.com/

Copy link
Member

@hwillson hwillson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this @kamerontanseli! I'll add a few small adjustments, then we'll get this merged.

@hwillson hwillson merged commit 11bdfba into apollographql:master May 31, 2019
woahitsraj pushed a commit to woahitsraj/apollo-client-devtools that referenced this pull request Oct 15, 2019
* fixed shema forward() null error

* Avoid creating a new Observable

* Changelog update
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

Successfully merging this pull request may close these issues.

ERROR: n(...).map is not a function
3 participants