W3C home > Mailing lists > Public > semantic-web@w3.org > March 2019

Re: graphql over graphs [Was: W3C Graph Data Workshop trip report]

From: Ruben Taelman <ruben.taelman@ugent.be>
Date: Sat, 9 Mar 2019 09:32:37 +0100
To: Juan Sequeda <juanfederico@gmail.com>, Eric Prud'hommeaux <eric@w3.org>
Cc: Semantic Web <semantic-web@w3.org>
Message-ID: <etPan.5c837a25.34262ac3.18a@ugent.be>
Hi Eric, Juan,

> Do you know if it actually supports graphs?

You can in fact use GraphQL to query graph structures.
However, you can only traverse them tree-based.
So in that sense, GraphQL is definitely less expressive
than SPARQL that can traverse graph-based.

> can I look for people that know same person or do I have to look for people who
> know a person with the same name?

As far as I know, these kinds of queries
are not directly possible by nesting fields in a GraphQL query.

However, in the GraphQL world, this could by achieved by introducing
a custom operation [1], like here:

```
{
  query PeopleKnowingPeopleWithSameName {
    name
  }
}
```

This is obviously not a very clean solution though.
Alternatively, a GraphQL interface could perhaps expose
virtual “knownBy” properties to achieve this kind of traversal.


As Juan has pointed, my position statement [2] talks about
ways to lift GraphQL queries to the RDF domain.
Not only does this allow RDF datasets to be queried,
but GraphQL queries actually become a bit more expressive than normal GraphQL.

For example, the query you described in SPARQL
can for example be expressed in GraphQL-LD [3],
which lifts GraphQL queries using a JSON-LD context.
The reason why this works here is because GraphQL-LD
allows you to traverse “back up the tree” using JSON-LD’s @reverse keyword.

An example query that uses this @reverse behaviour to find influenced people
on DBpedia that were influenced by the same person can be seen in [4].
Note that this query does not include filtering for the matches
where the two influenced people are equal.
(This kind of filtering is not supported yet)

[1] https://graphql.org/learn/queries/#operation-name
[2] https://rubensworks.github.io/article-w3cdataws2019-graphql/
[3] https://comunica.github.io/Article-ISWC2018-Demo-GraphQlLD/
[4] http://query.linkeddatafragments.org/#transientDatasources=http%3A%2F%2Ffragments.dbpedia.org%2F2016-04%2Fen&query=%7B%0A%20%20...%20on%20Person%20%7B%0A%20%20%20%20name%0A%20%20%20%20influences%20%7B%0A%20%20%20%20%20%20influenced1%3A%20influences%20%7B%0A%20%20%20%20%20%20%20%20influencedName1%3A%20name%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20influenced2%3A%20influences%20%7B%0A%20%20%20%20%20%20%20%20influencedName2%3A%20name%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D&queryContext=%7B%0A%20%20%22%40context%22%3A%20%7B%0A%20%20%20%20%22name%22%3A%20%7B%20%22%40id%22%3A%20%22http%3A%2F%2Fwww.w3.org%2F2000%2F01%2Frdf-schema%23label%22%2C%20%22%40language%22%3A%20%22en%22%20%7D%2C%0A%20%20%20%20%22Person%22%3A%20%7B%20%22%40id%22%3A%20%22http%3A%2F%2Fdbpedia.org%2Fontology%2FPerson%22%20%7D%2C%0A%20%20%20%20%22influences%22%3A%20%7B%20%22%40id%22%3A%20%22http%3A%2F%2Fdbpedia.org%2Fontology%2FinfluencedBy%22%2C%20%22%40reverse%22%3A%20true%20%7D%0A%20%20%7D%0A%7D&resultsToTree=false&queryFormat=graphql

Kind regards,
Ruben Taelman

On 9 March 2019 at 04:13:47, Juan Sequeda (juanfederico@gmail.com) wrote:

EricP,

Ruben Taelman is the person to answer your question. Check out his position paper:
https://www.w3.org/Data/events/data-ws-2019/assets/position/Ruben%20Taelman.pdf

--
Juan Sequeda, Ph.D
www.juansequeda.com


On Fri, Mar 8, 2019 at 4:33 PM Eric Prud'hommeaux <eric@w3.org> wrote:
On Fri, Mar 08, 2019 at 01:42:12PM -0500, Juan Sequeda wrote:
> All,
>
> I wrote my trip report on the W3C Graph Data workshop:
> http://www.juansequeda.com/blog/2019/03/08/w3c-graph-data-workshop-trip-report/

tx for the report! i'd hoped to go but a contract is taking a little
longer than hoped. (if there's another in the next 14 days, i can
probably go.)

I was interested in the graphql stuff. I know the graphql spec is
actually about trees but graphql is frequently used for graphs. Do you
know if it actually supports graphs? As a litmus for that, can I look
for people that know same person or do I have to look for people who
know a person with the same name? In SPARQL, the former:

SELECT ?whom {
  ?a foaf:knows ?whom .
  ?b foaf:knows ?whom .
  (FILTER ?a < ?b)
}

The latter relies on heuristics to because there's no graph identifier
on nodes. In SPARQL it would look kind of like:

SELECT ?whom {
  ?a foaf:knows [ foaf:name ?nameA ] .
  ?b foaf:knows [ foaf:name ?nameB ] .
  (FILTER ?nameA = ?nameB)
}

The latter is of course subject to false positives if multiple people
have the same name.


>  It was a successful event! In a nutshell
> – There is a unified and vibrant graph community.
> – A W3C Business Group will be formed and serve as a liaison between
> different interested parties.
> – There is a push for RDF*/SPARQL* to be a W3C Member submission.
> – There is interest to standardize a Property Graph data model with a
> schema.
> – There is interest to standardize mappings between Property Graphs and RDF.
>
> Best,
>
> Juan
>
>
>
> --
> Juan Sequeda, Ph.D
> www.juansequeda.com

--
-eric

office: +1.617.258.5741 32-G528, MIT, Cambridge, MA 02144 USA
mobile: +1.617.599.3509

(eric@w3.org)
Feel free to forward this message to any list for any purpose other than
email address distribution.
Received on Saturday, 9 March 2019 08:33:03 UTC

This archive was generated by hypermail 2.3.1 : Saturday, 9 March 2019 08:33:04 UTC