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

Named graphs do not retain id when expanded #24

Open
mpoffald opened this issue Aug 17, 2023 · 0 comments
Open

Named graphs do not retain id when expanded #24

mpoffald opened this issue Aug 17, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@mpoffald
Copy link
Contributor

Expanding a node which contains a @graph key just returns an array containing the expanded contents of the graph. Other top-level keys, such as any @id, are dropped.

For example, both of these expanded nodes should contain an :id of "http://example.com/myGraph":

;;1.
(node {:context {:ex "http://example.com/"
                 :id "@id"
                 :graph "@graph"}
       :id :ex/myGraph
       :graph [{:id :ex/foo
                :ex/bar true}]})
;;=>
[{:idx ["@graph" 0],
  :id "http://example.com/foo",
  "http://example.com/bar"
  {:value true, :type nil, :idx ["@graph" 0 :ex/bar]}}] 

;;2.
(node {"@context" {"ex" "http://example.com/"}
       "@id" "ex:myGraph"
       "@graph" [{"@id" "ex:foo"
                  "ex:bar" true}]})
;;=>
[{:idx ["@graph" 0],
  :id "http://example.com/foo",
  "http://example.com/bar"
  {:value true, :type nil, :idx ["@graph" 0 "ex:bar"]}}] 

Here is the example run through json-ld playground:

[
  {
    "@graph": [
      {
        "@id": "https://example.com/foo",
        "https://example.com/bar": [
          {
            "@value": true
          }
        ]
      }
    ],
    "@id": "https://example.com/myGraph"
  }
]

(json-ld playground link)

@mpoffald mpoffald added the bug Something isn't working label Aug 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant