A GraphQL endpoint for Datasette
Project description
datasette-graphql
A GraphQL endpoint for Datasette
Work in progress alpha - this has many missing features.
Try out a live demo at datasette-graphql-demo.datasette.io/graphql.
Installation
Install this plugin in the same environment as Datasette.
$ pip install datasette-graphql
Usage
This sets up /graphql
as a GraphQL endpoint for the first attached database. Individual tables can be queried like this:
{
repos {
id
full_name
description
}
}
If a column is a foreign key to another table, you can request columns of that table using a nested query like this:
{
repos {
id
full_name
owner {
id
login
}
}
}
You can filter the rows returned for a specific table using the filters:
argument. This accepts a list of filters, where a filter is a string of the form column=value
or column__op=value
. For example, to return just repositories with the Apache 2 license and more than 10 stars:
{
repos(filters: ["license=apache-2.0", "stargazers_count__gt=10"]) {
full_name
stargazers_count
license {
key
}
}
}
This is the same format used for querystring arguments to the Datasette table view, see column filter arguments in the Datasette documentation.
Still to come
See issues for a full list. Planned improvements include:
- Pagination
- Canned query support
- Ability to allowlist specific tables, views and canned queries
Development
To set up this plugin locally, first checkout the code. Then create a new virtual environment:
cd datasette-graphql
python3 -mvenv venv
source venv/bin/activate
Or if you are using pipenv
:
pipenv shell
Now install the dependencies and tests:
pip install -e '.[test]'
To run the tests:
pytest
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for datasette_graphql-0.1a3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a990b9daba2f3877bb169c1df50a2ee69fa31f57974fe45b4b2f3da4b404ecc |
|
MD5 | e4ac2e576a605084b2708f5334bd4ef5 |
|
BLAKE2b-256 | 81a74823768d7d18a52c249384675d925e30476cdb9786d3385fc396c712cdf7 |