w3c / json-ld-framing

JSON-LD 1.1 Framing Specification
https://w3c.github.io/json-ld-framing/
Other
24 stars 20 forks source link

Ex. 41 Playground doesn't contain `@omitGraph: false` + playground does not apply `@omitGraph` #116

Closed kuzdogan closed 1 year ago

kuzdogan commented 3 years ago

Example 41 on the document has the following description: EXAMPLE 41: Framed library objects with @omitGraph set to false, which indeed has the correct result output on the document.

However, upon clicking on "Open in playground" the frame does not contain the property @omitGraph. Interestingly the result is correct, i.e. contains @graph.

The playground has the following frame, note that @omitGraph is missing:

{
  "@context": {
    "@vocab": "http://example.org/"
  },
  "@type": "Library",
  "contains": {
    "@type": "Book",
    "contains": {
      "@type": "Chapter"
    }
  }
}

and the following output:

{
  "@graph": [
    {
      "@id": "http://example.org/library",
      "@type": "http://example.org/Library",
      "http://example.org/contains": {
        "@id": "http://example.org/library/the-republic",
        "@type": "http://example.org/Book",
        "http://example.org/contains": {
          "@id": "http://example.org/library/the-republic#introduction",
          "@type": "http://example.org/Chapter",
          "http://example.org/description": "An introductory chapter on The Republic.",
          "http://example.org/title": "The Introduction"
        },
        "http://example.org/creator": "Plato",
        "http://example.org/title": "The Republic"
      },
      "http://example.org/location": "Athens"
    },
    {
      "@id": "http://example.org/library/the-republic",
      "@type": "http://example.org/Book",
      "http://example.org/contains": {
        "@id": "http://example.org/library/the-republic#introduction",
        "@type": "http://example.org/Chapter",
        "http://example.org/description": "An introductory chapter on The Republic.",
        "http://example.org/title": "The Introduction"
      },
      "http://example.org/creator": "Plato",
      "http://example.org/title": "The Republic"
    },
    {
      "@id": "http://example.org/library/the-republic#introduction",
      "@type": "http://example.org/Chapter",
      "http://example.org/description": "An introductory chapter on The Republic.",
      "http://example.org/title": "The Introduction"
    }
  ]
}

But if one touches the frame and initiates a recompilation e.g. by adding a space and removing, the output does not have @graph anymore. So the following output is generated:

{
  "@context": {
    "@vocab": "http://example.org/"
  },
  "@id": "http://example.org/library",
  "@type": "Library",
  "contains": {
    "@id": "http://example.org/library/the-republic",
    "@type": "Book",
    "contains": {
      "@id": "http://example.org/library/the-republic#introduction",
      "@type": "Chapter",
      "description": "An introductory chapter on The Republic.",
      "title": "The Introduction"
    },
    "creator": "Plato",
    "title": "The Republic"
  },
  "location": "Athens"
}

I wasn't also able to apply the @omitGraph rule by manually adding it to the frame. I might be placing the property in the wrong place but the following frame produced an output without a @graph.

{
  "@context": {
    "@vocab": "http://example.org/"
  },
  "@omitGraph": false,
  "@type": "Library",
  "contains": {
    "@type": "Book",
    "contains": {
      "@type": "Chapter"
    }
  }
}
gkellogg commented 3 years ago

Definitely odd behavior. The Ruby implementation also doesn't seem to honor "@omitGraph": false. Not sure why it is included when you first open it; @davidlehn may have some idea.

In the case of the Ruby implementation (and I expect pyld and jsonld.js) it never actually looks for the @omitGraph keyword in the frame, only in either the invocation options, or based on the processorMode which defaults to json-ld1.1, so assumes "@omitGraph": false.

Also, looks like a couple of tests for @omitGraph would be in order.

gkellogg commented 3 years ago

Actually, looking further at the spec, there is no actual @omitGraph keyword defined. It is mentioned in the title of example 41, but it is only defined as a processor option, which takes a default value based on the processing mode.

Although the playground behavior is odd, the best correction is an editorial change to the title of Example 41.

It would be useful if the playground allowed this (and other options) to be set.

gkellogg commented 1 year ago

Summary:

Updated label on Example 41 to use omitGraph instead of @omitGraph, as omitGraph is an API option, not a framing keyword.