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

Collect result as array #20

Open
linonetwo opened this issue Jan 27, 2019 · 5 comments
Open

Collect result as array #20

linonetwo opened this issue Jan 27, 2019 · 5 comments
Labels
bug Something isn't working

Comments

@linonetwo
Copy link

linonetwo commented Jan 27, 2019

Can I do something likes:

{ ... on Container { contains contains { type[] } } }

To collect type field into an array?

Since currently

{ ... on Container { contains contains { type } } }

Returns

{​
"?contains": Object { id: "https://new-japanese-concise-tutorial.solid.authing.cn/public/textbook/new-japanese-concise-tutorial-chapter-1-table.csv" },
"?contains_type": Object { id: "http://www.w3.org/ns/iana/media-types/text/csv#Resource" }
}
​
{
"?contains": Object { id: "https://new-japanese-concise-tutorial.solid.authing.cn/public/textbook/new-japanese-concise-tutorial-chapter-1-table.csv" },
"?contains_type": Object { id: "http://www.w3.org/ns/ldp#Resource" }
​}

Object { "?contains_type": {…}, "?contains": {…} }
Object { "?contains_type": {…}, "?contains": {…} }

Which is quite redundent, it's better if I can collect ?contains_type field into an array and destructure the id:

{
"?contains": "https://new-japanese-concise-tutorial.solid.authing.cn/public/textbook/new-japanese-concise-tutorial-chapter-1-table.csv" },
"?contains_type": ["http://www.w3.org/ns/ldp#Resource", "http://www.w3.org/ns/iana/media-types/text/csv#Resource"]
​}

I've tried this to destructure, but it doesn't work on my endpoint ( and I didn't find a way to collect them into an array):

{ ... on Container { contains { id } contains { type { id } } } }
SELECT ?contains_id ?contains_type_id WHERE {
  OPTIONAL {
    ?b1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/ns/ldp#Container>;
      <http://www.w3.org/ns/ldp#contains> ?contains.
    ?contains <http://www.w3.org/1999/02/22-rdf-syntax-ns#id> ?contains_id.
    ?b1 <http://www.w3.org/ns/ldp#contains> ?contains.
    ?contains <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?contains_type.
    ?contains_type <http://www.w3.org/1999/02/22-rdf-syntax-ns#id> ?contains_type_id.
  }
}
@rubensworks rubensworks added the question Further information is requested label Jan 27, 2019
@linonetwo
Copy link
Author

linonetwo commented Jan 28, 2019

But executing graphql-to-sparql ~/Desktop/context.json "{ ... on Container { contains contains { type } } }" on

  "contains": { "@id": "http://www.w3.org/ns/ldp#contains", "@singular": true },
  "contains_type": { "@singular": false },

and

"contains": "http://www.w3.org/ns/ldp#contains",

results are the same, they are both:

SELECT ?contains ?contains_type WHERE {
  OPTIONAL {
    ?b1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/ns/ldp#Container>;
      <http://www.w3.org/ns/ldp#contains> ?contains, ?contains.
    ?contains <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?contains_type.
  }
}

And, what is @singularize? Is that a graphql directive?


update

Oh, this @singular seems to be a feature in comunica engine, so graphql-to-sparql cli don't use it.

But I can't get a list with comunica engine too.

@rubensworks
Copy link
Owner

@linonetwo How are you invoking Comunica exactly?

@linonetwo
Copy link
Author

linonetwo commented Jan 29, 2019

This is the code trying to query SoLiD POD:

https://github.com/linonetwo/new-japanese-concise-tutorial-interactive/blob/0db7b64c1b52b7da8a2c4449a3c9e3340008b52d/src/store/texts.ts#L107

And I'm using this JSON-LD context:

https://github.com/linonetwo/new-japanese-concise-tutorial-interactive/blob/0db7b64c1b52b7da8a2c4449a3c9e3340008b52d/src/store/ldpContext.json#L103

We are planning to use GraphQL in our SoLiD app to reduce developers' learning curve, so I made this demo project for a prior-art search, preparing some example codes.

@rubensworks
Copy link
Owner

This is the code trying to query SoLiD POD

Your code looks fine to me, so this must be a bug in GraphQL-LD or Comunica. I'll look into it when I have time.

We are planning to use GraphQL in our SoLiD app to reduce developers' learning curve, so I made this demo project for a prior-art search, preparing some example codes.

I see, interesting!

@rubensworks rubensworks added bug Something isn't working and removed question Further information is requested labels Jan 29, 2019
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

2 participants