Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@graph container support #549

Merged
merged 17 commits into from
Dec 7, 2017
Merged

@graph container support #549

merged 17 commits into from
Dec 7, 2017

Conversation

davidlehn
Copy link
Member

@davidlehn davidlehn commented Nov 16, 2017

Work-in-progress PR.

  • Add "@container": "@graph" expand/compact tests.
  • Add "@container": ["@graph", "@set"] expand/compact tests.
  • Add spec text.
  • Add support for additional @id or @index usage with @graph?

@davidlehn davidlehn added this to the JSON-LD 1.1 milestone Nov 16, 2017
@gkellogg
Copy link
Member

I'll get to my review this weekend, after completing my own implementation, thanks for doing the heavy lifting!

A concern is that, while this allows @graph containers, it doesn't really support named graphs, as the graphs created are anonymous with no possibility of reference, other than as the value of the property for which they're associated. Solving naming would requiring adding something like a @graphName keyword in the term definition, and could still be problematic if that name is a BNode. Probably best to address this as a simple issue, as this clearly solves an important use case, without having the ability to actually name the named graphs.

@davidlehn
Copy link
Member Author

@gkellogg Comments on recent commits:

I think the @graphId part needs a spec example or two. At first glance of spec text and tests, I'm still not sure how it works. Keyword should also be added to the "Syntax Tokens and Keywords" section. Unfortunate to need a camel case keyword. It's the only one outside of framing spec? Potential issue is that cap-eye-dee (Id) and lower-el-dee (ld) look the same in some fonts (like right here as I type). I could see that causing confusion.

Removing the highlight bit is unfortunate. Would be nice to find a better solution for that.

You marked off the @index part as done but I think I was unclear on what I meant there. I was suggesting perhaps we want to allow combining @id and @index with @graph in @container. And just to be complete, allow @set in there too. Not sure if this would help with the @graphId bit too? So you could do things like:

{
  "@context": {
    "@vocab": "ex:",
    "index-container": {
      "@id": "ex:index-container",
      "@container": ["@graph", "@index"]
    },
    "id-container": {
      "@id": "ex:id-container",
      "@container": ["@graph", "@id"]
    }
  },
  "index-container": {
    "idx1": { ... }
  },
  "id-container": {
    "ima:id": { ... }
  }
}

Which would expand out into something like:

[
  {
    "ex:index-container": [
      {
        "@graph": ...,
        "@index": "idx1"
      }
    ],
    "ex:id-container": [
      {
        "@graph": ...,
        "@id": "ima:id"
      }
    ]
  }
]

@gkellogg
Copy link
Member

I think the @GraphID part needs a spec example or two.

Sure

At first glance of spec text and tests, I'm still not sure how it works.

I'll, of course, add spec text; it's pretty straight-forward, but there may be some corner-cases to explore.

Keyword should also be added to the "Syntax Tokens and Keywords" section.

👍

Unfortunate to need a camel case keyword. It's the only one outside of framing spec? Potential issue is that cap-eye-dee (Id) and lower-el-dee (ld) look the same in some fonts (like right here as I type). I could see that causing confusion.

Open to suggestions, we could simply use @name.

Removing the highlight bit is unfortunate. Would be nice to find a better solution for that.

I've looked, and perhaps there's something hidden in highlight.js we could take advantage of. OTOH, it basically looks the same as it did in 1.0 (minus the diff-marking, which its just CSS).

You marked off the @Index part as done but I think I was unclear on what I meant there. I was suggesting perhaps we want to allow combining @id and @Index with @graph in @container.

What is done is that @container: @index can index graphs, but does not work with the @graph term logic. It's of dubious use, but was pretty simple. Absent use cases, maybe we should remove it and create issues to motivate other use cases.

@gkellogg
Copy link
Member

gkellogg commented Dec 2, 2017

@dlongley Thinking about it some more, it's probably better to use the "@container": ["@id", "@graph"] instead of introducing an @graphId (or perhaps @graphName keyword, which is not as flexible, as the name of the graph is fixed in the term definition. I'll need to spend some time on that, but (after making things consistent), I'm going to back out the @graphId changes and work on that.

gkellogg added a commit to ruby-rdf/json-ld that referenced this pull request Dec 4, 2017
@gkellogg
Copy link
Member

gkellogg commented Dec 6, 2017

@davidlehn and @dlongley Tests, syntax and algorithms are updated to reflect my implementation of basic graph containers, as well as the map versions. Please review.

Copy link
Member

@gkellogg gkellogg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it's good to go now.

@gkellogg
Copy link
Member

gkellogg commented Dec 7, 2017

@dlongley We have support for "@graph", ["@graph", "@set"], ["@graph", "@index"], ["@graph", "@index", "@set"], ["@graph", "@id"], ["@graph", "@id", "@set"].

I'm not sure how useful ["@graph", "@index", "@set"] and ["@graph", "@id", "@set"], as, unless a document had multiple graphs with the same name, this would never happen. It does complicate the language a bit, so I'm inclined to remove support for that.

The only argument to leave it, is that @set is valid with all other combinations, other than @list.

@gkellogg
Copy link
Member

gkellogg commented Dec 7, 2017

Fixes #195. Fixes #481

@dlongley
Copy link
Member

dlongley commented Dec 7, 2017

@gkellogg,

I'm not sure how useful ["@graph", "@Index", "@set"] and ["@graph", "@id", "@set"], as, unless a document had multiple graphs with the same name, this would never happen. It does complicate the language a bit, so I'm inclined to remove support for that.

The only argument to leave it, is that @set is valid with all other combinations, other than @list.

I think the ["@graph", "@index", "@set"] case doesn't require the same name for a graph... it could just could be a collection of unnamed graphs under a single index, right?

As for ["@graph", "@id", "@set"], if the only advantage is consistency for consistency's sake then it seems more compelling to remove support given that it complicates language and implementations with no real use cases. Of course, if supporting the @index combo version and not the @id combo version would make things even more complex, then it may as well stay. It would be good to get some more opinions though given that it looks like you've already put in the work to support both.

In any case, I'm +1 to merging the PR as is and happy defer any additional decisions to later/another PR. Great work, guys, I especially like that there was no need for an additional @graphId or similar keyword.

Copy link
Member

@dlongley dlongley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just needs rebasing due to conflicts.

@gkellogg
Copy link
Member

gkellogg commented Dec 7, 2017

As for ["@graph", "@id", "@set"], if the only advantage is consistency for consistency's sake then it seems more compelling to remove support given that it complicates language and implementations with no real use cases.

Looking at my implementation, I don't think it really makes implementation more complicated; one line in compaction, and a bit more complicated logic in error detection when looking at the term definition. The language in Syntax is slightly more complicated, but probably not worth changing now.

# Conflicts:
#	spec/latest/json-ld/index.html
@gkellogg gkellogg merged commit 3d92431 into master Dec 7, 2017
@gkellogg gkellogg deleted the graph-container branch December 7, 2017 17:27
has <code>@container</code> set to <code>@graph</code> are interpreted as
<a>implicitly named graphs</a>, where the associated graph name is either
assigned from a new <a>blank node identifier</a>, or defined using
<code>@graphId</code>.</li>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gkellogg Was this supposed to be removed?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this remains, and is what is used by verifiable credentials. We may need to add more about graph id and index containers, though.

What we removed was anything about graphId.

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

Successfully merging this pull request may close these issues.

3 participants