Skip to content
Open
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
9 changes: 9 additions & 0 deletions graphql/codegen-cli/codegen.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { defineConfig } from '@constructive-io/graphql-codegen';

export default defineConfig({
endpoint: 'http://app-public-APPNAME.localhost:3000/graphql',
output: './src/generated',
cli: { toolName: 'APPNAME' },
nodeHttpAdapter: true,
verbose: true,
});
33 changes: 33 additions & 0 deletions graphql/codegen-cli/generate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env ts-node
/**
* GraphQL Code Generation Script
*
* Usage:
* pnpm run codegen
*
*/

import { generate } from '@constructive-io/graphql-codegen';
import config from './codegen.config';

async function main() {
console.log('Starting GraphQL code generation...\n');

const result = await generate(config);

if (!result.success) {
console.error('\n', result.message);
if (result.errors?.length) {
result.errors.forEach((e) => console.error(' -', e));
}
process.exit(1);
}

console.log('\n', result.message);
console.log('\nGeneration complete!');
}

main().catch((err) => {
console.error('Fatal error:', err);
process.exit(1);
});
40 changes: 40 additions & 0 deletions graphql/codegen-cli/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "@constructive-templates/graphql-cli",
"version": "0.0.1",
"author": "____fullName____ <____email____>",
"private": true,
"main": "index.js",
"module": "esm/index.js",
"types": "index.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/____username____/____repoName____"
},
"license": "____license____",
"description": "____moduleDesc____",
"scripts": {
"copy": "copyfiles -f ../../LICENSE README.md package.json dist",
"clean": "rimraf dist/**",
"build": "pnpm run clean; tsc; tsc -p tsconfig.esm.json; pnpm run copy",
"codegen": "ts-node generate.ts"
},
"keywords": [],
"devDependencies": {
"@constructive-io/graphql-codegen": "^4.7.0",
"@types/node": "^20.19.29",
"copyfiles": "^2",
"esbuild": "^0.27.2",
"rimraf": "^5",
"ts-node": "^10.9.2",
"typescript": "^5"
},
"dependencies": {
"@0no-co/graphql.web": "^1.1.2",
"@constructive-io/graphql-types": "^3.1.1",
"appstash": "^0.5.0",
"gql-ast": "^3.1.0",
"graphql": "^16.9.0",
"inquirerer": "^4.5.2",
"nested-obj": "^0.2.1"
}
}
11 changes: 8 additions & 3 deletions graphql/codegen-react-query/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,19 @@
},
"keywords": [],
"devDependencies": {
"@constructive-io/graphql-codegen": "^4.7.0",
"@types/node": "^20.19.29",
"copyfiles": "^2",
"esbuild": "^0.27.2",
"rimraf": "^5",
"ts-node": "^10.9.2",
"typescript": "^5",
"@constructive-io/graphql-codegen": "^4.7.0"
"typescript": "^5"
},
"dependencies": {
"@tanstack/react-query": "^5.90.17"
"@0no-co/graphql.web": "^1.1.2",
"@constructive-io/graphql-types": "^3.1.1",
"@tanstack/react-query": "^5.90.17",
"gql-ast": "^3.1.0",
"graphql": "^16.9.0"
}
}
8 changes: 8 additions & 0 deletions graphql/codegen-schema/codegen.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { defineConfig } from '@constructive-io/graphql-codegen';

export default defineConfig({
endpoint: 'http://app-public-APPNAME.localhost:3000/graphql',
output: './schemas',
nodeHttpAdapter: true,
verbose: true,
});
44 changes: 44 additions & 0 deletions graphql/codegen-schema/generate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env ts-node
/**
* Schema-Only Generation Script
*
* Fetches the GraphQL schema and saves it to disk without generating code.
* Uses generate() with GenerateOptions directly (schemaOnly is not part of
* the defineConfig type surface, but is accepted by generate()).
*
* Usage:
* pnpm run codegen
*/

import { generate } from '@constructive-io/graphql-codegen';
import type { GenerateOptions } from '@constructive-io/graphql-codegen';
import config from './codegen.config';

async function main() {
console.log('Starting schema-only generation...\n');

const options: GenerateOptions = {
...config,
schemaOnly: true,
schemaOnlyOutput: config.output || './schemas',
schemaOnlyFilename: 'app-public.graphql',
};

const result = await generate(options);

if (!result.success) {
console.error('\n', result.message);
if (result.errors?.length) {
result.errors.forEach((e) => console.error(' -', e));
}
process.exit(1);
}

console.log('\n', result.message);
console.log('\nSchema generation complete!');
}

main().catch((err) => {
console.error('Fatal error:', err);
process.exit(1);
});
36 changes: 36 additions & 0 deletions graphql/codegen-schema/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "@constructive-templates/graphql-schema",
"version": "0.0.1",
"author": "____fullName____ <____email____>",
"private": true,
"main": "index.js",
"module": "esm/index.js",
"types": "index.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/____username____/____repoName____"
},
"license": "____license____",
"description": "____moduleDesc____",
"scripts": {
"copy": "copyfiles -f ../../LICENSE README.md package.json dist",
"clean": "rimraf dist/**",
"build": "pnpm run clean; tsc; tsc -p tsconfig.esm.json; pnpm run copy",
"codegen": "ts-node generate.ts"
},
"keywords": [],
"devDependencies": {
"@constructive-io/graphql-codegen": "^4.7.0",
"@types/node": "^20.19.29",
"copyfiles": "^2",
"rimraf": "^5",
"ts-node": "^10.9.2",
"typescript": "^5"
},
"dependencies": {
"@0no-co/graphql.web": "^1.1.2",
"@constructive-io/graphql-types": "^3.1.1",
"gql-ast": "^3.1.0",
"graphql": "^16.9.0"
}
}
66 changes: 0 additions & 66 deletions graphql/provision/README.md

This file was deleted.

79 changes: 79 additions & 0 deletions graphql/provision/blueprint.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{
"name": "REPLACE_WITH_DB_NAME",
"description": "REPLACE_WITH_APP_DESCRIPTION",
"schema": {
"tables": [
{
"name": "projects",
"fields": [
{ "name": "id", "type": "uuid", "isRequired": true, "isPrimaryKey": true, "defaultValue": "uuid_generate_v4()" },
{ "name": "created_at", "type": "timestamp", "defaultValue": "now()" },
{ "name": "updated_at", "type": "timestamp", "defaultValue": "now()" }
],
"policies": [
{
"policyType": "AuthzEntityMembership",
"policyData": { "entity_field": "entity_id", "membership_type": 2 },
"operations": ["create", "read", "update", "delete"]
}
]
},
{
"name": "tasks",
"fields": [
{ "name": "id", "type": "uuid", "isRequired": true, "isPrimaryKey": true, "defaultValue": "uuid_generate_v4()" },
{ "name": "title", "type": "text", "isRequired": true },
{ "name": "status", "type": "text", "defaultValue": "'pending'" },
{ "name": "description", "type": "text" },
{ "name": "created_at", "type": "timestamp", "defaultValue": "now()" },
{ "name": "updated_at", "type": "timestamp", "defaultValue": "now()" }
],
"relations": [
{
"kind": "belongs-to",
"fieldName": "project_id",
"targetTable": "projects",
"deleteAction": "c"
}
],
"policies": [
{
"policyType": "AuthzEntityMembership",
"policyData": { "entity_field": "entity_id", "membership_type": 2 },
"operations": ["create", "read", "update", "delete"]
}
]
},
{
"name": "tags",
"fields": [
{ "name": "id", "type": "uuid", "isRequired": true, "isPrimaryKey": true, "defaultValue": "uuid_generate_v4()" },
{ "name": "name", "type": "text", "isRequired": true }
],
"relations": [
{
"kind": "many-to-many",
"targetTable": "projects",
"junctionTableName": "project_tags",
"useCompositeKey": true,
"deleteAction": "c",
"policies": [
{
"policyType": "AuthzEntityMembership",
"policyData": { "entity_field": "entity_id", "membership_type": 2 },
"operations": ["create", "read", "delete"]
}
]
}
],
"policies": [
{
"policyType": "AuthzEntityMembership",
"policyData": { "entity_field": "entity_id", "membership_type": 2 },
"operations": ["create", "read", "update", "delete"]
}
]
}
]
}
}
29 changes: 0 additions & 29 deletions graphql/provision/package.json

This file was deleted.

Loading