npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

twinql

v0.11.2

Published

A graph query language for the semantic web

Downloads

28

Readme

twinql

Build Status Coverage Status

A graph query language for the semantic web. Not SPARQL.

Use Cases

twinql was designed with the goal of scratching a particular itch: fetching linked data over LDP without having to imperatively follow every link and handle every error in an ad-hoc manner in Solid applications.

The main idea behind twinql is that queries select subgraphs by starting at a particular node and traversing outwards. The query and the response have a similar recursive tree structure so that the shape of the response can be inferred from the shape of the request.

It is currently a hobby project and quite limited in scope. It cannot do many of the things that SPARQL can. However, it attempts to be more ergonomic than SPARQL for common use cases.

Examples

Here's how you would query a WebID for profile data and data of that person's friends:

@prefix foaf http://xmlns.com/foaf/0.1/

https://dan-f.databox.me/profile/card#me {
  foaf:name
  foaf:img
  [ foaf:knows ] {
    foaf:name
    foaf:img
  }
}

Response:

{
  "@context": {
    "foaf": "http://xmlns.com/foaf/0.1/"
  },
  "@id": "https://dan-f.databox.me/profile/card#me",
  "foaf:name": { "@value": "Daniel Friedman" },
  "foaf:img": { "@value": "https://dan-f.databox.me/profile/me.jpg"},
  "foaf:knows": [
    {
      "@id": "https://deiu.me/profile#me",
      "foaf:name": {"@value": "Andrei Vlad Sambra" },
      "foaf:img": {"@value": "https://deiu.me/avatar.jpg" }
    },
    {
      /* ... */
    }
  ]
}

Goals

  • Be declarative
  • Work well with existing standards and tools
  • Make app-building easier
  • Support multiple persistence layers (in-memory, link following, SPARQL, etc)
  • Be implemented eventually on the server to improve performance when querying within a single domain and to reduce data being sent over the network

Known Challenges

  • Link-following is slow
  • Not all linked data actually links as well as it should
  • LDP doesn't care how much data you want from a particular graph; it gives you the whole thing
  • Just about no operation on the semantic web is atomic

Roadmap

  • ordering and pagination
  • response streaming
  • Mutation API

Other cool things

  • Create higher level tooling for offline-first querying and realtime updates
  • Create bindings for common UI libraries
    • e.g. connected React component

Development

This reference implementation of twinql happens to be built in JS for quick prototyping, but a safer language is recommended when implementing for a production use case.

Contributing

If you want to contribute to this reference implementation, first reach out by creating a Github Issue to make sure we're on the same page :smile:

Assuming you want to mess with the code, just do the following:

  1. Make sure you have node >=7.x and npm installed.

  2. Clone the repo

$ git clone https://github.com/dan-f/twinql.git # (or your fork)
  1. Install the dependencies
$ cd twinql && npm install
  1. Run the demo site
$ npm start
  1. Build the lib
# You can run webpack in watch mode to rebuild the UMD bundle on file changes.
# This is useful when prototyping with the demo site.
$ npm run build:dev

# To test the minified UMD build:
$ npm run build:umd

# To transpile the library to CommonJS ES5
$ npm run build:lib