Graphcool / graphcool-framework

Apache License 2.0
1.77k stars 131 forks source link

Data import from CLI does not work in 0.11.4 #451

Open marktani opened 6 years ago

marktani commented 6 years ago

Issue by nickluger Sunday Jan 07, 2018 at 14:33 GMT Originally opened as https://github.com/graphcool/prisma/issues/1535


Current behavior

gcf import --source ./seed.zip leads to:

  config homepath /Users/xxx/.graphcoolrc +0ms
  config localRCPath /Users/xxx/xxx/xxxx/.graphcoolrc +0ms
  config globalRCPath /Users/nick/.graphcoolrc +0ms
TypeError: Cannot read property 'modules' of undefined
    at Import.<anonymous> (/Users/nick/.config/yarn/global/node_modules/graphcool-cli-core/src/commands/import/index.ts:39:47)
    at step (/Users/nick/.config/yarn/global/node_modules/graphcool-cli-core/dist/commands/import/index.js:42:23)
    at Object.next (/Users/nick/.config/yarn/global/node_modules/graphcool-cli-core/dist/commands/import/index.js:23:53)
    at fulfilled (/Users/nick/.config/yarn/global/node_modules/graphcool-cli-core/dist/commands/import/index.js:14:58)
    at <anonymous>
Exiting with code: 1

Reproduction

I'm using graphcool-framework/0.11.4. It's installed globally. This error happens for any zip file. Even if i put a movie in it, so i assume its not a problem with the data...

Expected behavior?

It should import data correctly.

marktani commented 6 years ago

Comment by marktani Sunday Jan 07, 2018 at 14:37 GMT


Could you please provide a minimal example that reproduces this error? 🙂

It should contain

Thanks!

marktani commented 6 years ago

Comment by nickluger Monday Jan 08, 2018 at 05:33 GMT


Hey thank you for the fast answer! 😃 here's the example!

I'm sorry, i was invoking the command from another directory. The error is resolved, if invoked from the project folder.

But even if i get no error message now,

no data gets imported, if i zip the files manually

using any zip tool.

You can check this out: https://github.com/nickluger/graphcool-manual-zip-error

If i gcf import --source export-2018-01-08T05/13/08.150Z.zip i get all data imported correctly. I assume it uses this exporter.

The file seed.zip was created by unzipping export-2018-01-08T05/13/08.150Z.zip and simply rezipping it via zip -r seed.zip export-2018-01-08T05/13/08.150Z.zip.

If you gcf import --source seed.zip, you get no error, but there is no data imported neither..

marktani commented 6 years ago

Comment by nickluger Monday Jan 08, 2018 at 05:46 GMT


I'm currently using this for seeding. I have a seed directory checked out in source control and would like to seed the database using something like zip -r ... && gcf import .... If there is a smarter or alternative way to seed the db, i would be happy to know. 😄

jharmon141 commented 6 years ago

I get this error when running prisma import --data ./data.zip:

raven@2.3.0 alert: failed to send exception to sentry: HTTP Error (413): undefined
Error: invalid signature: 0xa
    at /usr/local/lib/node_modules/prisma/node_modules/unzip/lib/parse.js:59:13
    at runCallback (timers.js:773:18)
    at tryOnImmediate (timers.js:734:5)
    at processImmediate [as _immediateCallback] (timers.js:711:5)
WirthAware commented 6 years ago

I have the same issue with graphcool-framework 0.11.5 Running it localy with npx Also tested it running with global install, with same effect
Also tested installing graphcool-framework as global, with same error

npx graphcool import --source data/<name>.zip --target <target_name>
graphcool -v
graphcool-framework/0.11.5 (darwin-x64) node-v8.7.0
Unzipping... ⣯
raven@2.4.0 alert: failed to send exception to sentry: HTTP Error (429): Creation of this event was denied due to rate limiting
Error: invalid signature: 0x80014
    at /<project>/node_modules/unzip/lib/parse.js:59:13
    at runCallback (timers.js:785:20)
    at tryOnImmediate (timers.js:747:5)
    at processImmediate [as _immediateCallback] (timers.js:718:5)
Melv commented 6 years ago

Also get this error

graphcool --version
graphcool-framework/0.11.5 (linux-x64) node-v6.10.3
Unzipping... ⣷
Error: invalid signature: 0x80014
    at /usr/lib/node_modules/graphcool/node_modules/unzip/lib/parse.js:59:13
    at runCallback (timers.js:672:20)
    at tryOnImmediate (timers.js:645:5)
    at processImmediate [as _immediateCallback] (timers.js:617:5)

Before getting this error I also get warnings regarding graphcool.yml

[WARNING] in <path to>/graphcool.yml: A valid option to satisfy the declaration 'opt:target' could not be found.

 ▸    [WARNING] in <path to>/graphcool.yml: Trying to populate non string value into a string for variable ${opt:target}.
 ▸    Please make sure the value of the property is a string.

something to do with the target, but just deploying to this target, with this graphcool.yml works

marktani commented 6 years ago

Hey @WirthAware, @Melv, when you unzip the folder and import the unzipped folder, does it work then?

steve-a-jones commented 6 years ago

Wrote a quick to get this to work.. (see graphcool-cli-core/dist/commands/import)

        var _this = this;
        return new Promise(function (resolve, reject) {
            var before = Date.now();
            _this.out.action.start('Unzipping');

            Minizip.unzip(_this.importPath, _this.importDir, function(err) {
                if (err)
                  console.log(err);
                else {
                    _this.out.action.stop(chalk_1.default.cyan(Date.now() - before + "ms"));
                    resolve();
                }

            });

            // var output = unzip.Extract({ path: _this.importDir });
            // fs.createReadStream(_this.importPath).pipe(output);
            // output.on('close', function () {
            //     _this.out.action.stop(chalk_1.default.cyan(Date.now() - before + "ms"));
            //     resolve();
            // });
        });
    };

But now I am getting another error Field type Json has no validator defined. Is importing Json not supported?

niwaa commented 6 years ago

@steve-a-jones

I think I found a workaround fix:

In : graphcool/node_modules/graphcool-cli-core/dist/commands/import/Importer.js

Replace the node-unzip library with this one: https://github.com/mhr3/unzip-stream (after installing it as a dependency).

// var unzip = require("unzip");
var unzip = require("unzip-stream");

I was able to import 20k sample nodes on mac-os, but will do more testing.

This fixed my "Error: invalid signature: 0x80014" errors.

juanpprieto commented 6 years ago

I'm also getting this error while trying to import the shared cluster nodes into my local. From project's root graphcool import --source export-2018-03-22T07:32:37.816Z.zip --target dev

cli-engine:plugins:manager requiring /usr/local/lib/node_modules/graphcool/node_modules/graphcool-cli-core +0ms cli-engine:plugins:manager required +3s plugin required command +3s EnvironmentMigrator graphcoolPath /Users/jpprietobaez/.graphcool does not exist +0ms Unzipping...Error: invalid signature: 0x80014 at /usr/local/lib/node_modules/graphcool/node_modules/unzip/lib/parse.js:59:13 at runCallback (timers.js:800:20) at tryOnImmediate (timers.js:762:5) at processImmediate [as _immediateCallback] (timers.js:733:5) Exiting with code: 1

Tried @niwaa unzip-stream workaround but it didnt fix it for me.

I get the error with both the untouched exported zip and also if I re-zip the folder. graphcool-framework/0.11.5 (darwin-x64) node-v9.2.1