Problem on data import using the CLI?


#1

I am trying to import data to my project called “server”. I follow the docs about data import however, I am lost. The type that I want to import data is named as “RateRule”:

  1. I prepared the following NDF structure in my server folder that I created with graphcool init server command :

data > nodes > 001.json

{
“valueType” : “nodes”,
“values” : [
{
"_typeName": “RateRule”,
“country”: “BULGARIA”,
“countryCode”: “BG”,
“maxLWH”: 300,
“maxLength”: 150,
“maxWeight”: 15000,
“method”: “Parcel Post Airmail”,
“minWeight”: 14000,
“rate”: 22400
},

}

  1. Then I zipped the "data " folder and typed below terminal command:

graphcool import --source data.zip

  1. I got the following response from terminal:

Unzipping… 60ms
Validating data… 7ms

Uploading nodes…
Uploading nodes done 1ms

Uploading lists
Uploading lists done 0ms

Uploading relations
Uploading relations done 1ms

  1. I checked my console and refresh the table but nothing has changed.

Could you help me? May be I understand something incorrectly?

Thank you very much,


Graphcool Framework and Prisma
#2

Hey,

could you post the schema that your project has as well please? And I do not see a value for id in your sample. Could you try adding a unique id per node? The id should be a string of length <= 25.


#3

this is a problem I’m having as well

I export some data I manually created in prisma, open the zip, rezip that file, and I cannot reimport that zip in a new stage. Please provide some better docs for us to follow.

update:

The import works when I import the exact zip that I exported, but fails when I unzip the file then rezip it without altering any content in the files.


#4

Thank you for the answers. It seems that ID was my problem. Thank you.


#5

Hi @giray123

can you explain what exactly you did to make it work? I have an id field in my data, but showing the exact error you had.

nvm i got it


#6

Hi @yellow_world,

Here is the things that I did. Hope it can help you:

  1. I added a unique ID (25 char string) to each node using a library through NodeJS
  2. I did not use Graphcool CLI to import but RAW API to import the data. I used Postman to do this. I created a POST method to “Project_URL/import” with body contains my NDF. You should add your Token to this request. (You can find your token on Graphcool Console > Project Settings > Authentication)
  3. Unfortunately, it gave me a SERVER error, telling me to contact with support. I guessed it was due to the large body size (although my NDF was 2,3 MB and docs says that max limit is 10 MB, I do not know the exact reason). So I split my data into chunks of 2500 nodes each. (my data consisted of about 11k nodes).
  4. I imported each chunk separately which worked!

Hope it helps.


#7

Hi giray123,

What library did you use to add your unique IDs to each node?

Thanks!


#9

I used below lib for its simplicity:
https://github.com/klughammer/node-randomstring

var uid_generator= require('shortid');
var uid= uid_generator.generate(25);