Giter Site home page Giter Site logo

Comments (12)

stubailo avatar stubailo commented on September 25, 2024

Odd, that code doesn't appear in this package - what's the stack trace?

from persistgraphql.

mitjade avatar mitjade commented on September 25, 2024

[1] .../GitHunt-React/server_bundle.js:98859
[1] import 'whatwg-fetch';
[1] ^^^^^^
[1] SyntaxError: Unexpected token import
[1] at Object.exports.runInThisContext (vm.js:78:16)
[1] at Module._compile (module.js:543:28)
[1] at Object.Module._extensions..js (module.js:580:10)
[1] at Module.load (module.js:488:32)
[1] at tryModuleLoad (module.js:447:12)
[1] at Function.Module._load (module.js:439:3)
[1] at Module.runMain (module.js:605:10)
[1] at run (bootstrap_node.js:420:7)
[1] at startup (bootstrap_node.js:139:9)
[1] at bootstrap_node.js:535:3

Got this just by updating apollo-client on GitHunt-React.

from persistgraphql.

Poincare avatar Poincare commented on September 25, 2024

Ah. We briefly removed the whatwg-fetch polyfill within Apollo Client. I'm not sure what that has to do with this tool but could you try updating to the latest AC?

from persistgraphql.

mitjade avatar mitjade commented on September 25, 2024

Tried v0.8.1, same thing.

I get the same problem when I try to follow https://github.com/apollostack/GitHunt-React/pull/176/files when I add to my project:
import { PersistedQueryNetworkInterface } from 'extractgql/lib/browser'

I guess whatwg-fetch is not the problem here, but it has something to do with import, webpack and ssr, will try to figure out what I'm doing wrong.

from persistgraphql.

ex0ns avatar ex0ns commented on September 25, 2024

Hi,
Did you find a solution ?
I use Meteor and I had the same problem when trying to import PersistedQueryNetworkInterface, the issue seems to come from https://github.com/apollographql/apollo-client/blob/master/src/transport/networkInterface.ts#L1, it seems to be a ES6 compatibility issue, coming from one of the build tool (I did not find a (clean) solution though).

As I only wanted to test this package, what I did (hacky) was to change var networkInterface_1 = require("apollo-client/transport/networkInterface"); to var networkInterface_1 = require("apollo-client"); in the generated ApolloNetworkInterface.js

I believe that #9 would solve this issue as Request is exported by apollo-client/index.js as opposed to QueryAndOptions

ex0ns

from persistgraphql.

mitjade avatar mitjade commented on September 25, 2024

Hi,

Current GitHunt-React and GitHunt-API examples still do not work for me, if I update 'apollo-client'.
Will wait for #9 to get merged and try again.

But was able to get it working with 0.6.0, by updating 'persistgraphql' to 0.2.10.

from persistgraphql.

ex0ns avatar ex0ns commented on September 25, 2024

Yes,

I wonder if this is not a module issue between apollo-client which uses es2015 import and and persistgraphql which is based on commonJS imports.

I noticed that changing 'apollo-client' to 0.8.1 in devDependencies generates

import 'whatwg-fetch';
import { print } from 'graphql-tag/printer';
export function printRequest(request) {

in node_modules/apollo-client/transport/networkInterface.js

Whereas 'apollo-client' 0.6 generates

require("whatwg-fetch");
var printer_1 = require("graphql-tag/printer");
function printRequest(request) {

I don't know where this come from (probably related to apollo-client) but, I think that there is definitely an issue with version of apollo-client (see apollographql/apollo-client@4f76c57#diff-e5e546dd2eb0351f813d63d1b39dbc48)
ex0ns

from persistgraphql.

dotansimha avatar dotansimha commented on September 25, 2024

I think that there is an issue with the compiled file /apollo-client/transport/networkInterface.js - is that okay that import ... is in use? I think is should be require(...).

As a temporary workaround, add this to your Webpack loaders config:

        {
          test: /node_modules\/apollo-client\/transport\/networkInterface\.js$/,
          loader: 'babel'
        },

from persistgraphql.

mitjade avatar mitjade commented on September 25, 2024

Should I raise an issue in "apollo-client"?

from persistgraphql.

dotansimha avatar dotansimha commented on September 25, 2024

@mitjade I am not sure it related directly to apollo-client, since import ... is valid ES6 imports syntax.
Maybe it can be solved if using Webpack and Babel config with es6 imports.

from persistgraphql.

dotansimha avatar dotansimha commented on September 25, 2024

The actual error is thrown because this package imports from inner files of apollo-client/.../.. (https://github.com/apollographql/persistgraphql/blob/master/src/network_interface/ApolloNetworkInterface.ts#L5) instead of loading those from the main package apollo-client.

from persistgraphql.

Poincare avatar Poincare commented on September 25, 2024

Those imports can now be removed because I believe Apollo Client now exports those from the main package.

from persistgraphql.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.