Skip to content

Commit aabe85e

Browse files
committed
feat: add @constructive-io/react package with React Query hooks and JSDoc comments
1 parent 46879ad commit aabe85e

1,480 files changed

Lines changed: 213809 additions & 7558 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

pnpm-lock.yaml

Lines changed: 2847 additions & 7558 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/constructive-react/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# GraphQL SDK
2+
3+
<p align="center" width="100%">
4+
<img height="120" src="https://raw.githubusercontent.com/constructive-io/constructive/refs/heads/main/assets/outline-logo.svg" />
5+
</p>
6+
7+
<!-- @constructive-io/graphql-codegen - DO NOT EDIT -->
8+
9+
## APIs
10+
11+
| API | Endpoint | Generators | Docs |
12+
|-----|----------|------------|------|
13+
| admin | - | React Query, ORM | [./src/admin/README.md](./src/admin/README.md) |
14+
| auth | - | React Query, ORM | [./src/auth/README.md](./src/auth/README.md) |
15+
| objects | - | React Query, ORM | [./src/objects/README.md](./src/objects/README.md) |
16+
| public | - | React Query, ORM | [./src/public/README.md](./src/public/README.md) |
17+
18+
---
19+
20+
Built by the [Constructive](https://constructive.io) team.
21+
22+
## Disclaimer
23+
24+
AS DESCRIBED IN THE LICENSES, THE SOFTWARE IS PROVIDED "AS IS", AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND.
25+
26+
No developer or entity involved in creating this software will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of the code, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value.
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{
2+
"name": "@constructive-io/react",
3+
"version": "0.0.1",
4+
"author": "Constructive <developers@constructive.io>",
5+
"description": "Constructive React - Auto-generated React Query hooks and ORM client",
6+
"main": "index.js",
7+
"module": "esm/index.js",
8+
"types": "index.d.ts",
9+
"homepage": "https://github.com/constructive-io/constructive",
10+
"license": "MIT",
11+
"publishConfig": {
12+
"access": "public",
13+
"directory": "dist"
14+
},
15+
"repository": {
16+
"type": "git",
17+
"url": "https://github.com/constructive-io/constructive"
18+
},
19+
"bugs": {
20+
"url": "https://github.com/constructive-io/constructive/issues"
21+
},
22+
"scripts": {
23+
"clean": "makage clean",
24+
"prepack": "npm run build",
25+
"build": "makage build",
26+
"build:dev": "makage build --dev",
27+
"generate": "tsx scripts/generate-react.ts",
28+
"lint": "eslint . --fix",
29+
"test": "jest --passWithNoTests",
30+
"test:watch": "jest --watch"
31+
},
32+
"keywords": [
33+
"graphql",
34+
"sdk",
35+
"orm",
36+
"react-query",
37+
"tanstack-query",
38+
"constructive",
39+
"postgraphile",
40+
"schema-dir"
41+
],
42+
"dependencies": {
43+
"@0no-co/graphql.web": "^1.1.2",
44+
"@constructive-io/graphql-types": "workspace:^",
45+
"@tanstack/react-query": "^5.90.19",
46+
"gql-ast": "workspace:^",
47+
"graphql": "^16.12.0"
48+
},
49+
"peerDependencies": {
50+
"react": "^18.0.0 || ^19.0.0"
51+
},
52+
"devDependencies": {
53+
"@constructive-io/graphql-codegen": "workspace:^",
54+
"@types/node": "^20.12.7",
55+
"@types/react": "^19.2.8",
56+
"makage": "^0.1.12",
57+
"react": "^19.2.3",
58+
"tsx": "^4.19.0",
59+
"typescript": "^5.9.3"
60+
}
61+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import {
2+
generateMulti,
3+
expandSchemaDirToMultiTarget,
4+
} from '@constructive-io/graphql-codegen';
5+
6+
const SCHEMA_DIR = '../constructive-sdk/schemas';
7+
8+
const EXCLUDE_TARGETS = ['private'];
9+
10+
async function main() {
11+
console.log('Generating React SDK from schema files...');
12+
console.log(`Schema directory: ${SCHEMA_DIR}`);
13+
14+
const baseConfig = {
15+
schemaDir: SCHEMA_DIR,
16+
output: './src',
17+
orm: true,
18+
reactQuery: true,
19+
verbose: true,
20+
docs: {
21+
agents: false,
22+
mcp: false,
23+
skills: true
24+
}
25+
};
26+
27+
const expanded = expandSchemaDirToMultiTarget(baseConfig);
28+
if (!expanded) {
29+
console.error('No .graphql files found in schema directory.');
30+
console.error('Ensure .graphql schema files exist in the schemas/ directory.');
31+
process.exit(1);
32+
}
33+
34+
for (const target of EXCLUDE_TARGETS) {
35+
if (target in expanded) {
36+
delete expanded[target];
37+
console.log(`Excluding target: ${target}`);
38+
}
39+
}
40+
41+
console.log(`Found targets: ${Object.keys(expanded).join(', ')}`);
42+
43+
const { results, hasError } = await generateMulti({
44+
configs: expanded,
45+
});
46+
47+
let realError = false;
48+
49+
for (const { name, result } of results) {
50+
if (result.success) {
51+
console.log(`[${name}] ${result.message}`);
52+
if (result.tables?.length) {
53+
console.log(` Tables: ${result.tables.join(', ')}`);
54+
}
55+
} else if (result.message?.includes('No tables found')) {
56+
console.log(`[${name}] SKIP: no tables (empty schema)`);
57+
} else {
58+
console.error(`[${name}] ERROR: ${result.message}`);
59+
realError = true;
60+
}
61+
}
62+
63+
if (realError) {
64+
console.error('\nReact SDK generation failed for one or more targets');
65+
process.exit(1);
66+
}
67+
68+
console.log('\nReact SDK generation completed successfully!');
69+
}
70+
71+
main().catch((err) => {
72+
console.error('Fatal error:', err);
73+
process.exit(1);
74+
});
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Generated GraphQL SDK
2+
3+
<p align="center" width="100%">
4+
<img height="120" src="https://raw.githubusercontent.com/constructive-io/constructive/refs/heads/main/assets/outline-logo.svg" />
5+
</p>
6+
7+
<!-- @constructive-io/graphql-codegen - DO NOT EDIT -->
8+
9+
## Overview
10+
11+
- **Tables:** 28
12+
- **Custom queries:** 10
13+
- **Custom mutations:** 2
14+
15+
**Generators:** ORM, React Query
16+
17+
## Modules
18+
19+
### ORM Client (`./orm`)
20+
21+
Prisma-like ORM client for programmatic GraphQL access.
22+
23+
```typescript
24+
import { createClient } from './orm';
25+
26+
const db = createClient({
27+
endpoint: 'https://api.example.com/graphql',
28+
});
29+
```
30+
31+
See [orm/README.md](./orm/README.md) for full API reference.
32+
33+
### React Query Hooks (`./hooks`)
34+
35+
Type-safe React Query hooks for data fetching and mutations.
36+
37+
```typescript
38+
import { configure } from './hooks';
39+
import { useCarsQuery } from './hooks';
40+
41+
configure({ endpoint: 'https://api.example.com/graphql' });
42+
```
43+
44+
See [hooks/README.md](./hooks/README.md) for full hook reference.
45+
46+
---
47+
48+
Built by the [Constructive](https://constructive.io) team.
49+
50+
## Disclaimer
51+
52+
AS DESCRIBED IN THE LICENSES, THE SOFTWARE IS PROVIDED "AS IS", AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND.
53+
54+
No developer or entity involved in creating this software will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of the code, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value.

0 commit comments

Comments
 (0)