0.1.6 • Published 7 years ago

sparql-connect v0.1.6

Weekly downloads
10
License
MIT
Repository
github
Last release
7 years ago

sparql-connect

sparql-connect allows to write sparql queries alongside React components in order to feed them with the query results.

It uses redux to store the status of each query and its results. Hence, a query will not be sent to the server if the results are available locally. It creates dedicated actions for each kind of query, so we can easily track the queries for debugging purpose (with redux-devtools for instance).

Install

npm install --save sparql-connect

You will need React to write your components, redux to manage the state of your application, and react-redux to connect your components to the state. You should probably have them already installed, but if not you can install them with:

npm install --save react redux react-redux

How to use it

For a complete guide, see documentation.

import { sparqlConnect, setQueryURL } from 'sparql-connect'

//Set the sparql endpoint (should be done once for the whole application)
setQueryURL('http://example.com/sparql')

//Write a query that returns some resources with the additional field `label`
const query = `
  SELECT ?resource ?label
  WHERE { ... } 
`
//Create a connector to populate the component with the results
const connector = sparqlConnect(query)

//Write your components assuming the query results will be available as a prop
//named `results`
function ResourcesList({ results }) {
  return (
    <ul>
      {
        results.map(({ resource, label }) => 
          <li key={resource}>{ label }</li>
        )
      }
    </ul>
  )
}

//Connect the query to your component
export default connector(ResourcesList)

Sparql queries validation

This library uses SPARQL.js to check the query syntax and add some possible missing prefixes (more precisely, it uses the jison grammar from SPARQL.js).

0.1.6

7 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago

0.0.12

7 years ago

0.0.11

7 years ago

0.0.10

7 years ago

0.0.9

8 years ago

0.0.8

8 years ago

0.0.7

8 years ago

0.0.6

8 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago

0.0.1

8 years ago