Skip to content
This repository has been archived by the owner on Apr 28, 2023. It is now read-only.

expected atleast one query in bulk #10

Open
thebetterjort opened this issue Dec 15, 2019 · 5 comments
Open

expected atleast one query in bulk #10

thebetterjort opened this issue Dec 15, 2019 · 5 comments

Comments

@thebetterjort
Copy link

thebetterjort commented Dec 15, 2019

What does this error mean ?

Verifying URL... Done!
Processing JSON data... Done!
Checking database... Skipped!
Creating tables... Done!
Tracking tables... Done!
Creating relationships... Error
{
  "path": "$",
  "error": "expected atleast one query in bulk",
  "code": "bad-request"
}

This example works:

{
    "post": [
        { "id": 1, "title": "Lorem Ipsum", "views": 254, "user_id": 123 },
        { "id": 2, "title": "Sic Dolor amet", "views": 65, "user_id": 456 }
    ],
    "user": [
        { "id": 123, "name": "John Doe" },
        { "id": 456, "name": "Alison Craus" }
    ],
    "comment": [
        { "id": 987, "post_id": 1, "body": "Consectetur adipiscing elit", "user_id": 123 },
        { "id": 995, "post_id": 2, "body": "Nam molestie pellentesque dui", "user_id": 456 },
        { "id": 999, "post_id": 1, "body": "quid agis", "user_id": 456 }
    ]
}

My simple json does not:


{
  "events": [
    {
      "id": 1,
      "case": "xxxx",
      "link": "https://google.com",
      "document": "18",
      "time": "02:30 PM",
      "description": "doc18",
      "AllJudges": "Hearing John Doe.",
      "HearingJudge": "John Doe",
      "PresiderJudge": "Doe John"
    },
    {
      "id": 1,
      "case": "xxxx",
      "link": "https://google.com",
      "document": "18",
      "time": "02:30 PM",
      "description": "doc18",
      "AllJudges": "Hearing John Doe.",
      "HearingJudge": "John Doe",
      "PresiderJudge": "Doe John"
    }
  ]
}
@birdwell
Copy link

I'm getting this error as well. I think it's because there is no relationships. In the example, there is relationship with comments and posts. It shouldn't be expected that there will be a relationship.

@shahidhk
Copy link
Member

shahidhk commented Dec 17, 2019

@birdwell @thebetterjort you can do the following as a workaround until this issue is fixed:

git clone [email protected]:hasura/json2graphql.git
cd json2graphql

# edit src/import/import.js
# comment lines 22 and 27
# save

npm ci
./bin/run https://hasura-test.herokuapp.com --db=./events.json

@birdwell
Copy link

@shahidhk Thank you, I will try that.

@thebetterjort
Copy link
Author

import.js

      // createRelationships(tables, url, headers).then(() => {
        cli.action.stop('Done!');
        cli.action.start('Inserting data');
        const insertOrder = getInsertOrder(tables);
        insertData(insertOrder, db, tables, url, headers);
      // });

RUN:

./bin/run https://myappthatImade.herokuapp.com --db=./events.json --overwrite

Error:

Verifying URL... Done! 
Processing JSON data... Done!
Checking database... Skipped!
Creating tables... Done!
Tracking tables... Done! 
Creating relationships... Done!
Inserting data... Error
{
  "graphQLErrors": [
    {
      "extensions": {
        "path": "$.selectionSet.insert_events.args.objects",
        "code": "constraint-violation"
      },
      "message": "Uniqueness violation. duplicate key value violates unique constraint \"events_pkey\""
    }
  ],
  "networkError": null,
  "message": "GraphQL error: Uniqueness violation. duplicate key value violates unique constraint \"events_pkey\""
}

my events.json

{
    "events": [
      {
        "id": 1,
        "case": "xxxx",
        "link": "https://google.com",
        "document": "18",
        "time": "02:30 PM",
        "description": "doc18",
        "AllJudges": "Hearing John Doe.",
        "HearingJudge": "John Doe",
        "PresiderJudge": "Doe John"
      },
      {
        "id": 1,
        "case": "xxxx",
        "link": "https://google.com",
        "document": "18",
        "time": "02:30 PM",
        "description": "doc18",
        "AllJudges": "Hearing John Doe.",
        "HearingJudge": "John Doe",
        "PresiderJudge": "Doe John"
      }
    ]
  }

@thebetterjort
Copy link
Author

thebetterjort commented Dec 18, 2019

My test json didn't have unique keys. This does solve the issue. I should have used my normalized data.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants