comunica / comunica-feature-link-traversal

πŸ“¬ Comunica packages for link traversal-based query execution
Other
8 stars 11 forks source link

QueryEngine doesn't perform link traversal out of the box #56

Closed mrkvon closed 2 years ago

mrkvon commented 2 years ago

Issue type:


Description:

When importing QueryEngine from @comunica/query-sparql-link-traversal v0.0.2-alpha.2.0 in a minimal Node (v17.9.0) + Typescript project, the link traversal doesn't work. I.e. only the sources that are provided beforehand get visited.

import { QueryEngine } from '@comunica/query-sparql-link-traversal'

;(async () => {
  const myEngine = new QueryEngine()

  const bindingsStream = await myEngine.queryBindings(
    `
      PREFIX foaf: <http://xmlns.com/foaf/0.1/>
      PREFIX mypod: <https://mrkvon.solidcommunity.net/profile/card#>
      PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
      SELECT DISTINCT ?interest ?label
      WHERE {
        mypod:me foaf:topic_interest ?interest.
        ?interest rdfs:label ?label.
        FILTER(lang(?label)='en')
      }`,
    {
      sources: ['https://mrkvon.solidcommunity.net/profile/card'],
      lenient: true,
    },
  )
  // Do something with the results, but there are no results
})()

On the other hand, when we set up the engine as follows, the link traversal works as expected:

import { QueryEngineFactory } from '@comunica/query-sparql-link-traversal'

;(async () => {
  const myEngine = await new QueryEngineFactory().create({
    configPath:
      'https://raw.githubusercontent.com/comunica/comunica-feature-link-traversal/master/engines/query-sparql-link-traversal/config/config-default.json',
  })

  // The same query as above, or other .......
  // Do something with the results, and yay, we have some!
})()

Environment:

@comunica/query-sparql-link-traversal v0.0.2-alpha.2.0 (installed with yarn add @comunica/query-sparql-link-traversal Node v17.9.0 Arch Linux

What else do you need to know?

github-actions[bot] commented 2 years ago

Thanks for reporting!

Maximvdw commented 2 years ago

Running npm run prepare to recompile the config fixes the issue - so I think a new build would fix it

EDIT: To test, I tried it in my node_modules\@comunica\query-sparql-link-traversal directory

mrkvon commented 2 years ago

I just tried to clone this repository, yarn, and run

node engines/query-sparql-link-traversal/bin/query.js https://mrkvon.solidcommunity.net/profile/card "
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX mypod: <https://mrkvon.solidcommunity.net/profile/card#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT DISTINCT ?interest ?label
WHERE {                                  
  mypod:me foaf:topic_interest ?interest.
  ?interest rdfs:label ?label.
  FILTER(lang(?label)='en')
}" --lenient

And it does perform the link traversal as expected. πŸŽ‰

So perhaps the issue is specific to the particular package version (@comunica/query-sparql-link-traversal v0.0.2-alpha.2.0), or to usage in node...

mrkvon commented 2 years ago

@Maximvdw That's awesome. This npm run prepare fixes my issue, too. πŸš€

When a new package version is released, let me know, I can test it and then this may be good to close. πŸŽ‰

mrkvon commented 2 years ago

Running npm run prepare to recompile the config fixes the issue - so I think a new build would fix it

EDIT: To test, I tried it in my node_modules\@comunica\query-sparql-link-traversal directory

With this fix, I can use the library in React, too. πŸŽ‰

rubensworks commented 2 years ago

@mrkvon new alpha build released: 0.0.2-alpha.3.0

Thanks for testing @Maximvdw!