levelgraph / levelgraph-jsonld

The Object Document Mapper for LevelGraph based on JSON-LD
113 stars 16 forks source link

Colliding keyword detection fails on "id" mapped to "@id" #40

Closed BigBlueHat closed 7 years ago

BigBlueHat commented 7 years ago

The code that generates the error is here: https://github.com/mcollina/levelgraph-jsonld/blob/e07ce027b0c4da9a5e2a8b5b34b394f95940379c/build/levelgraph-jsonld.js#L5239-L5245

A sample JSON-LD document + @context that will cause the error to be thrown is here:

{
  "@context": {
    "id": "@id",
    "@vocab": "http://xmlns.com/foaf/0.1/"
  },
  "id": "http://bigbluehat.com/#",
  "name": "BigBlueHat",
  "knows": [

    {
      "id": "http://manu.sporny.org#person",
      "name": "Manu Sporny",
      "homepage": "http://manu.sporny.org/"
    }
  ]
}

I found this because the [Web Annotation Data Model]() (among others) maps id to @id in this way.

Removing the 3rd line in the above example will make it work.

You can try pasting it in the playground I'm building for this project. 🎁 😍 https://bigbluehat.github.io/levelgraph-playground/ (watch the console if you try it)

Not sure what the extra JSON-LD validation is meant for...so I don't just want to rip it out. 😄 Hence this issue. 😁

Thanks! 🎩

mcollina commented 7 years ago

Wow, nice project!!! Would you like to add a link to the README? We are publishing an updated version of this in the next few days, then you can try if it solves your issue!

cc @jmatsushita

jmatsushita commented 7 years ago

Super cool! I'll add a test for this and see if the update solves it or what I can do. I thought I'd seen the id: @id trick somewhere but forgot about it and I need it in my project so thanks!

jmatsushita commented 7 years ago

Ok so the bad news is that our update doesn't solve it, but the good news is that I found the bug. Stay tuned.

BigBlueHat commented 7 years ago

@mcollina I'd be honored to add a link in the README. Thanks! I was happy with how quickly it came together, and I hope it'll be a useful foundation for more levelgraph usage and graph/hexastore know-how. :smiley:

I'll get some links and info added into the playground app and then send a PR for the link.

@jmatsushita thanks for all you're doing here also! 😁

jmatsushita commented 7 years ago

Hey @BigBlueHat let us know if v1.0.0 fixes it!

BigBlueHat commented 7 years ago

Thanks @jmatsushita! LevelGraph Playground is up to date. 😃 📅 😁