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

Frame aliasing @graph broken when omitGraph = false #257

Closed
lolgab opened this issue May 2, 2023 · 4 comments · Fixed by #288
Closed

Frame aliasing @graph broken when omitGraph = false #257

lolgab opened this issue May 2, 2023 · 4 comments · Fixed by #288
Milestone

Comments

@lolgab
Copy link
Contributor

lolgab commented May 2, 2023

Describe the bug
I want to rename the @graph name to something like data to have a Json output which can be consumed by applications that are not aware of Linked Data. This doesn't seem to work on titanium-json-ld

To Reproduce
Steps to reproduce the behavior:
Given this frame:

{
  "@context": {
    "data": "@graph"
  }
}

and this Json-LD:

{
  "@graph": [
    {
      "@id": "http://example.org/foo",
      "http://example.org/name": "Foo"
    },
    {
      "@id": "http://example.org/bar",
      "http://example.org/name": "Bar"
    }
  ]
}

Framing with the omitGraph = false option returns:

{
  "@graph": [
    {
      "data": [
        {
          "@id": "http://example.org/foo",
          "http://example.org/name": "Foo"
        },
        {
          "@id": "http://example.org/bar",
          "http://example.org/name": "Bar"
        }
      ]
    }
  ],
  "@context": {
    "data": "@graph"
  }
}

Where the JSON-LD Playground returns:

{
  "@context": {
    "data": "@graph"
  },
  "data": [
    {
      "@id": "http://example.org/bar",
      "http://example.org/name": "Bar"
    },
    {
      "@id": "http://example.org/foo",
      "http://example.org/name": "Foo"
    }
  ]
}

Expected behavior
My expectation is to have the same result as JSON-LD Playground

{
  "@context": {
    "data": "@graph"
  },
  "data": [
    {
      "@id": "http://example.org/bar",
      "http://example.org/name": "Bar"
    },
    {
      "@id": "http://example.org/foo",
      "http://example.org/name": "Foo"
    }
  ]
}
@lolgab lolgab changed the title Frame Renaming @graph gives strange result Frame aliasing @graph gives strange result May 2, 2023
@lolgab
Copy link
Contributor Author

lolgab commented May 6, 2023

@filip26 do you have any idea why this happens and what is needed to fix it? I could try to open a PR.
The official w3c test suite doesn't cover this use case, but from the specification it seems to be supported. Do you know if my expectation is correct in first place? Thank you!

@filip26
Copy link
Owner

filip26 commented May 6, 2023

@lolgab the spec allows to alias any keyword except @context.The first step is to create a test case.
Please note, framing algorithm processes an input + frame in an expanded form. see line 116 and 119. If the result of expansion is correct then there could be bug in the framing algorithm implementation.

lolgab added a commit to lolgab/titanium-json-ld that referenced this issue Nov 17, 2023
lolgab added a commit to lolgab/titanium-json-ld that referenced this issue Nov 17, 2023
lolgab added a commit to lolgab/titanium-json-ld that referenced this issue Nov 17, 2023
@lolgab
Copy link
Contributor Author

lolgab commented Nov 17, 2023

I managed to reproduce the error in tests and fix it :)

@lolgab lolgab changed the title Frame aliasing @graph gives strange result Frame aliasing @graph broken when omitGraph = false Nov 17, 2023
@filip26
Copy link
Owner

filip26 commented Nov 18, 2023

@lolgab excellent, thank you! Please check the second test case, see my comment on PR.

filip26 added a commit that referenced this issue Nov 18, 2023
Fix #257 Frame aliasing `@graph` with omitGraph=true
@filip26 filip26 added this to the 1.3.3 milestone Nov 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants