3 ms·
Funny, I’m currently working on a project where I’m fetching post data from a Wordpress backend with a few GQL queries via the WPGraphQL plug-in and `@urql/svel
by FractalHQ 5y ago
Funny, I’m currently working on a project where I’m fetching post data from a Wordpress backend with a few GQL queries via the WPGraphQL plug-in and `@urql/svelte` to populate a static SSG’d frontend. While developing locally, I copied and pasted the JSON response into a local file in the repo to develop against. I was thinking this would be nice to automate.
If I’m understanding correctly, it seems like this tool more or less automates that process?
Can it send a GQL query?
- idan 5y agoThis is a really powerful use-case! If you saw Alex Gaynor's election tracker[1] during the US 2020 elections, it's exactly how it worked. Actions scraped the NYT election results.json, and a static site on GH pages rendered the data, XHRing the scraped JSON out of the repo periodically. There's no GraphQL backend yet! We've only done HTTP and SQL backends so far. If your GQL query is simple enough, you might be able to squeak by with an HTTP flat action whose target is https://your.site/graphql?query=whatever https://your.site/graphql?query=whatever ? [1] https://alex.github.io/nyt-2020-election-scraper/battleground-state-changes.html# https://alex.github.io/nyt-2020-election-scraper/battlegroun...
- simonw 5y agoIf you want to run GraphQL queries against this kind of data I have a roundabout way of doing it: 1. Set up a repo that uses actions to scrape data into a CSV 2. Set up another action that converts that CSV to SQLite (using my sqlite-utils tool) and then... 3. Publishes that database to Cloud Run or Vercel with Datasette and with the datasette-graphql plugin Here's an example repo that does exactly that: https://github.com/simonw/cdc-vaccination-history https://github.com/simonw/cdc-vaccination-history It scrapes vaccination data from the CDC, complies that into a SQLite database and publishes it using Datasette on Vercel at https://cdc-vaccination-history.datasette.io/ https://cdc-vaccination-history.datasette.io/ Then you can run GraphQL queries at https://cdc-vaccination-history.datasette.io/graphql https://cdc-vaccination-history.datasette.io/graphql (Here's the plugin: https://datasette.io/plugins/datasette-graphql https://datasette.io/plugins/datasette-graphql) Another demo: https://covid-19.datasettes.com/graphql https://covid-19.datasettes.com/graphql runs from this repo: https://github.com/simonw/covid-19-datasette https://github.com/simonw/covid-19-datasette