aruntk / polymer-apollo

🚀 Polymer Apollo Integration
MIT License
78 stars 7 forks source link

Problem with polymer-apollo babel output ? #1

Closed atoy40 closed 7 years ago

atoy40 commented 7 years ago

Hello, i'm trying tu use your project on a polymer/graphql application i'm working on, and i've a problem I've "webpacked" my js code andload it into the browser with a script tag, but when it's loaded, i get a :

_polymerApollo2.default is not a constructor

Maybe this part of the webpack output can help you to help me :) :

    var _apolloClient = __webpack_require__(2);

    var _apolloClient2 = _interopRequireDefault(_apolloClient);

    var _polymerApollo = __webpack_require__(65);

    var _polymerApollo2 = _interopRequireDefault(_polymerApollo);

    function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

    // Create the apollo client
    var apolloClient = new _apolloClient2.default({
      networkInterface: (0, _apolloClient.createNetworkInterface)({
        uri: 'http://localhost:8080/graphql',
        transportBatching: true
      }),
      queryTransformer: _apolloClient.addTypename
    });

    //create a new polymer behavior from PolymerApollo class. 
    PolymerApolloBehavior = new _polymerApollo2.default({ apolloClient: apolloClient });

I've used the chromium debbuger, and it seems _polymerApollo2 has no property "default". A problem with the "babelisation" done at npm install ? (apollo-client class own a default property and constructs well)

thks, and don't hesitate to ask me more informations :)

aruntk commented 7 years ago

PolymerApolloBehavior = new _polymerApollo2.default({ apolloClient: apolloClient });

Check what happens if you change this line to

PolymerApolloBehavior = new _polymerApollo2({ apolloClient: apolloClient });

By the way Its already converted to es5 before publishing to npm.

atoy40 commented 7 years ago

Same error : _polymerApollo2 is not a constructor

aruntk commented 7 years ago

console.log(_polymerApollo2); ?

atoy40 commented 7 years ago

this is working : new _polymerApollo2.PolymerApollo({ apolloClient: apolloClient });

atoy40 commented 7 years ago

ok, i've found :

import PolymerApollo from 'polymer-apollo';

as to be

import { PolymerApollo } from 'polymer-apollo';
atoy40 commented 7 years ago

so it's just a small mistake in your README :)

aruntk commented 7 years ago

@atoy40 Oh. Okay. Sorry for that. I've changed the readme. Thanks for reporting. closing the issue. :)