Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 7 additions & 21 deletions .github/workflows/run-tests.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: PostgreSQL tests
name: LaunchQL tests
on:
push:
workflow_dispatch:
Expand Down Expand Up @@ -37,29 +37,15 @@ jobs:
--health-retries 5

steps:
# - name: Install Git
# run: apk add --no-cache git

# TODO remove deps on git config
- name: Configure Git (for tests)
run: |
git config --global user.name "CI Test User"
git config --global user.email "ci@example.com"

# - name: Install Sqitch on Alpine
# run: |
# apk add --no-cache curl make perl perl-utils perl-dev build-base \
# libpq libpq-dev postgresql-dev \
# perl-dbd-pg perl-dbi perl-dbd-sqlite \
# cpanminus

# cpanm --notest --quiet App::Sqitch

- name: checkout
uses: actions/checkout@v4

# - name: deps
# run: apk update && apk add bash git python3-dev make g++

- name: deps
run: yarn

Expand Down Expand Up @@ -92,14 +78,14 @@ jobs:
- name: launchql/uuid-stream
run: cd ./packages/uuid-stream && yarn test

- name: launchql/query-builder
run: cd ./packages/query-builder && yarn test

- name: launchql/introspectron
run: cd ./packages/introspectron && yarn test

- name: launchql/react-client
run: cd ./packages/react-client && yarn test
- name: launchql/query-builder
run: cd ./packages/query-builder && yarn test

- name: launchql/query
run: cd ./packages/query && yarn test

- name: launchql/launchql-gen
run: cd ./packages/launchql-gen && yarn test
Expand Down
3 changes: 1 addition & 2 deletions packages/introspectron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
"test:watch": "jest --watch"
},
"dependencies": {
"graphql-tag": "2.12.5",
"lodash": "4.17.20"
"graphql-tag": "2.12.5"
}
}
4 changes: 1 addition & 3 deletions packages/introspectron/src/introspect.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// @ts-nocheck
import { makeIntrospectionQuery } from './query';
import { parseTags } from './utils';
import flatMap from 'lodash/flatMap';

export const introspect = async (
pgClient,
Expand Down Expand Up @@ -66,8 +65,7 @@ export const introspect = async (
});
});

const extensionConfigurationClassIds = flatMap(
result.extension,
const extensionConfigurationClassIds = result.extension.flatMap(
(e) => e.configurationClassIds
);
result.class.forEach((klass) => {
Expand Down
79 changes: 45 additions & 34 deletions packages/react-client/README.md → packages/query/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# @launchql/react-client
# `@launchql/query`

<p align="center" width="100%">
<img height="250" src="https://github.com/user-attachments/assets/d0456af5-b6e9-422e-a45d-2574d5be490f" />
Expand All @@ -9,57 +9,68 @@
<img height="20" src="https://github.com/launchql/launchql-2.0/actions/workflows/run-tests.yaml/badge.svg" />
</a>
<a href="https://github.com/launchql/launchql-2.0/blob/main/LICENSE-MIT"><img height="20" src="https://img.shields.io/badge/license-MIT-blue.svg"/></a>
<a href="https://www.npmjs.com/package/@launchql/react-client"><img height="20" src="https://img.shields.io/github/package-json/v/launchql/launchql-2.0?filename=packages%react-client%2Fpackage.json"/></a>
<a href="https://www.npmjs.com/package/@launchql/query"><img height="20" src="https://img.shields.io/github/package-json/v/launchql/launchql-2.0?filename=packages%query%2Fpackage.json"/></a>
</p>

Generate GraphQL mutations/queries
> Fluent GraphQL query and mutation builder for PostGraphile-based schemas.

## Installation

```sh
npm install @launchql/react-client
npm install @launchql/query
```

## Why Use `@launchql/query`?

* ⚡ Build complex, nested GraphQL queries fluently
* ✅ Schema-aware via introspection (PostGraphile optimized)
* 🧠 Prevents common query syntax issues
* 🧩 Designed for composability and clean syntax

## Usage

```js
import { Client } from '@launchql/react-client';
```ts
import { Client } from '@launchql/query';

const client = new Client({
introspection: { ...queries, ...mutations }
introspection: { ...queries, ...mutations } // provide your GraphQL schema metadata
});

const result = client
.query('Action')
.edges(true)
.getMany({
select: {
id: true,
name: true,
photo: true,
title: true,
actionResults: {
select: {
id: true,
actionId: true
},
variables: {
first: 10,
before: null,
filter: {
name: {
in: ['abc', 'def']
},
actionId: { equalTo: 'dc310161-7a42-4b93-6a56-9fa48adcad7e' }
const result = client
.query('Action')
.edges(true)
.getMany({
select: {
id: true,
name: true,
photo: true,
title: true,
actionResults: {
select: {
id: true,
actionId: true
},
variables: {
first: 10,
before: null,
filter: {
name: {
in: ['abc', 'def']
},
actionId: {
equalTo: 'dc310161-7a42-4b93-6a56-9fa48adcad7e'
}
}
}
}
})
.print();
}
})
.print();
```

# output
## Output

```gql
```graphql
query getActionsQuery(
$first: Int
$last: Int
Expand Down Expand Up @@ -111,4 +122,4 @@ query getActionsQuery(
}
}
}
```
```
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const path = require('path');
const fs = require('fs');
const intro = require('introspectron');
const client = require('@launchql/react-client');
const builder = require('@launchql/query');

function generateIntrospectionFixture() {
const inDir = path.resolve(
Expand Down Expand Up @@ -35,7 +35,7 @@ function generateMetaObjectFixture() {
const outDir = path.resolve(__dirname, './api/meta-obj.json');
fs.readFile(inDir, { encoding: 'utf8' }, (err, data) => {
if (err) return console.log(err);
const converted = client.MetaObject.convertFromMetaSchema(JSON.parse(data));
const converted = builder.MetaObject.convertFromMetaSchema(JSON.parse(data));
fs.writeFile(outDir, JSON.stringify(converted), (err) => {
if (err) return console.log(err);
console.log('DONE');
Expand Down
Loading