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

Feature Suggestion: Using JSON-LD for Gizmo results #820

Closed
iddan opened this issue Sep 12, 2019 · 10 comments
Closed

Feature Suggestion: Using JSON-LD for Gizmo results #820

iddan opened this issue Sep 12, 2019 · 10 comments
Milestone

Comments

@iddan
Copy link
Collaborator

iddan commented Sep 12, 2019

Description
Currently, Gizmo returns JSONs of strings which may or may not be valid n3 values. This is a non-standard behaviour that is hard to integrate with other systems.

Examples
Results of IRIs:

{ "@id": "bob" }

Results of literals:

"Bob"

Results of literals with language:

{ "@language": "en", "@value": "Bob" }

Results of literals with type:

{
    "@value": "2010-05-29T14:17:39+02:00",
    "@type": "http://www.w3.org/2001/XMLSchema#dateTime"
}

All together

{
   "id": { "@id": "bob" },
   "name": "Bob",
   "englishName": { "@value": "Bob", "@language": "en" },
   "timeCreated": {
      "@value": "2010-05-29T14:17:39+02:00",
      "@type": "http://www.w3.org/2001/XMLSchema#dateTime"
   }
}

Future Proposals

  • It might be better to change id default property
@dennwc
Copy link
Member

dennwc commented Sep 12, 2019

Totally agree on this! Also, don't forget TypedString, it's probably { "@value": "xxx", "@type": "yyy" }.

@iddan
Copy link
Collaborator Author

iddan commented Sep 12, 2019

Updated the description

@dennwc
Copy link
Member

dennwc commented Sep 12, 2019

Also, in "future proposals", do you mean changing id to @id? Sounds like a good idea.

The change mentioned above will break things already, so it will be HTTP API v2, and we can easily change the default id tag as well.

@iddan
Copy link
Collaborator Author

iddan commented Sep 12, 2019

Yeah, it will look like that:

{
  "@id": "bob",
  "name": "Bob",
  "englishName": { "@value": "Bob", "@language": "en" },
  "timeCreated": {
    "@value": "2010-05-29T14:17:39+02:00",
    "@type": "http://www.w3.org/2001/XMLSchema#dateTime"
  }
}

@iddan
Copy link
Collaborator Author

iddan commented Sep 12, 2019

Later, we can streamline the format in GraphQL as well as done in: https://github.com/rubensworks/GraphQL-LD.js

@iddan
Copy link
Collaborator Author

iddan commented Sep 13, 2019

Took a deeper look into Gremlin. It seems like you need to be explicit about the return type you get there.
To get nodes:

g.V()

To get values:

g.V(1).values('name')

To get tags

g.V().as('a').out().as('b').out().as('c').select('a','b','c')

Which I find more explicit and simple.

With JSON-LD the results will be:

{ "@id": "bob" }
"Bob"
{ "a": { "@id": "bob" }, "b": { "@id": "alice" }, "c": { "@id": "steve" } }

@iddan
Copy link
Collaborator Author

iddan commented Sep 15, 2019

Here is a basic implementation: #821

@iddan
Copy link
Collaborator Author

iddan commented Sep 19, 2019

@dennwc what do you think about the previous comment?

@dennwc
Copy link
Member

dennwc commented Sep 19, 2019

@iddan It's definitely a nicer way for selecting results. May also help the optimizer to some extent.

@iddan
Copy link
Collaborator Author

iddan commented Oct 2, 2019

Merged #821

@iddan iddan closed this as completed Oct 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants