1
Fork 0
mirror of https://github.com/Airsequel/AirGQL.git synced 2025-10-08 19:00:41 +02:00
[MIRROR] Automatically generate a GraphQL API for any SQLite database
Find a file
prescientmoon 2ee5152d54 Implement querying by PK
- I realised by PK querying doesn't need arguments like filter, limit or
offset, so I removed the argument name collision logic I added in the
last commit
- I implemented the actual logic for querying by PK. The code is a lot
shorter due to the new introspection system
- I moved the normal queries to the new introspection system for
consistency.
- I moved the logic of "coerce columns without a datatype" away from the
resolver and into the "sql -> gql" converter as to be able to reuse the
default introspection resolver which simply looks up fields into the
parent resolver's result.
- I added some comments documenting the Introspection.Resolver stuff and
it's behaviour
2024-11-14 18:01:55 +01:00
app AirGQL: Clean up documentation, remove obsolete references to Airsequel 2024-05-03 08:39:25 +00:00
images AirGQL: Clean up documentation, remove obsolete references to Airsequel 2024-05-03 08:39:25 +00:00
source Implement querying by PK 2024-11-14 18:01:55 +01:00
tests Ensure sql names are always quoted properly 2024-10-01 02:02:19 +02:00
.gitignore AirGQL: Clean up documentation, remove obsolete references to Airsequel 2024-05-03 08:39:25 +00:00
makefile AirGQL: Add make targets release & docs, set hash of first commit 2024-05-03 08:47:15 +00:00
package.yaml AirGQL: Bump version to 0.7.1.3 2024-06-08 15:07:19 +00:00
readme.md Upgrade Stackage LTS version of AirGQL as well 2024-06-06 20:08:52 +00:00
Setup.hs AirGQL: Clean up documentation, remove obsolete references to Airsequel 2024-05-03 08:39:25 +00:00
stack-standalone.yaml Update stack resolver for airgql 2024-09-05 14:16:40 +02:00
stack-standalone.yaml.lock Lock Deno version in Dockerfile 2024-10-11 11:01:07 +00:00

AirGQL

Automatically generate a GraphQL API for an SQLite database.

Diagram of SQL to GraphQL conversion

How It Works

It analyses the database schema and builds the corresponding GraphQL introspection and data resolvers.

The generated API supports all basic CRUD operations and even complex queries and mutations including filters and pagination.

It is designed to be either used a Haskell library for integrating GraphQL support into existing servers or as a standalone CLI app for quickly spinning up a backend.

AirGQL is the core component of Airsequel, which provides a complete solution for building web applications on top of SQLite databases.

Installation

CLI Tool

You can install the CLI app using Stack:

git clone https://github.com/Airsequel/AirGQL
cd AirGQL
make install

Library

You can also use AirGQL in your Haskell project by adding the Hackage package as a dependency to your package.yaml or your *.cabal file:

dependencies:
  - airgql
  - 

Also set the lib-only flag in your stack.yaml file to avoid irrelevant errors:

flags:
  airgql:
    lib-only: true

Usage

CLI App

Run following command to start a GraphQL API server for an existing SQLite database:

stack run -- serve tests/example.sqlite

Then you can query the API like this:

http POST http://localhost:4189/graphql \
  query='query {
    songs(limit: 2) {
      id
      title
    }
  }'

It also supports mutations:

http POST http://localhost:4189/graphql \
  query='mutation {
    insert_songs(objects: [{ title: "New Song" }]) {
      returning {
        id
        title
      }
    }
  }'

Check out the documentation at docs.airsequel.com/graphql-api for more details on how to use all of its GraphQL features.

Library

Check out the code in app/Main.hs file for an example of how to build a simple Servant server leveraging AirGQL.