@objectql/server 1.7.3 → 1.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/LICENSE +21 -118
- package/dist/adapters/graphql.d.ts +17 -0
- package/dist/adapters/graphql.js +460 -0
- package/dist/adapters/graphql.js.map +1 -0
- package/dist/adapters/rest.d.ts +7 -5
- package/dist/adapters/rest.js +51 -14
- package/dist/adapters/rest.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/server.js +33 -0
- package/dist/server.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/package.json +6 -4
- package/src/adapters/graphql.ts +523 -0
- package/src/adapters/rest.ts +48 -14
- package/src/index.ts +2 -0
- package/src/server.ts +42 -0
- package/src/types.ts +1 -1
- package/test/graphql.test.ts +439 -0
- package/test/rest-advanced.test.ts +455 -0
- package/test/rest.test.ts +236 -0
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @objectql/server
|
|
2
2
|
|
|
3
|
+
## 1.8.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Patch release with documentation updates and bug fixes
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @objectql/core@1.8.1
|
|
10
|
+
- @objectql/types@1.8.1
|
|
11
|
+
|
|
12
|
+
## 1.8.0
|
|
13
|
+
|
|
14
|
+
### Minor Changes
|
|
15
|
+
|
|
16
|
+
- Release minor version 1.8.0
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- Updated dependencies
|
|
21
|
+
- @objectql/core@1.8.0
|
|
22
|
+
- @objectql/types@1.8.0
|
|
23
|
+
|
|
3
24
|
## 1.7.3
|
|
4
25
|
|
|
5
26
|
### Patch Changes
|
package/LICENSE
CHANGED
|
@@ -1,118 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
to
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
## Distribution License
|
|
23
|
-
|
|
24
|
-
The licensor grants you an additional copyright license
|
|
25
|
-
to distribute copies of the software. Your license
|
|
26
|
-
to distribute covers distributing the software with
|
|
27
|
-
changes and new works permitted by [Changes and New Works
|
|
28
|
-
License](#changes-and-new-works-license).
|
|
29
|
-
|
|
30
|
-
## Notices
|
|
31
|
-
|
|
32
|
-
You must ensure that anyone who gets a copy of any part of
|
|
33
|
-
the software from you also gets a copy of these terms or the
|
|
34
|
-
URL for them above, as well as copies of any plain-text lines
|
|
35
|
-
beginning with `Required Notice:` that the licensor provided
|
|
36
|
-
with the software. For example:
|
|
37
|
-
|
|
38
|
-
> Required Notice: Copyright ObjectQL Contributors (https://github.com/objectql)
|
|
39
|
-
|
|
40
|
-
## Changes and New Works License
|
|
41
|
-
|
|
42
|
-
The licensor grants you an additional copyright license to
|
|
43
|
-
make changes and new works based on the software for any
|
|
44
|
-
permitted purpose.
|
|
45
|
-
|
|
46
|
-
## Patent License
|
|
47
|
-
|
|
48
|
-
The licensor grants you a patent license for the software that
|
|
49
|
-
covers patent claims the licensor can license, or becomes able
|
|
50
|
-
to license, that you would infringe by using the software.
|
|
51
|
-
|
|
52
|
-
## Fair Use
|
|
53
|
-
|
|
54
|
-
You may have "fair use" rights for the software under the
|
|
55
|
-
law. These terms do not limit them.
|
|
56
|
-
|
|
57
|
-
## No Other Rights
|
|
58
|
-
|
|
59
|
-
These terms do not allow you to sublicense or transfer any of
|
|
60
|
-
your licenses to anyone else, or prevent the licensor from
|
|
61
|
-
granting licenses to anyone else. These terms do not imply
|
|
62
|
-
any other licenses.
|
|
63
|
-
|
|
64
|
-
## Patent Defense
|
|
65
|
-
|
|
66
|
-
If you make any written claim that the software infringes or
|
|
67
|
-
contributes to infringement of any patent, your patent license
|
|
68
|
-
for the software granted under these terms ends immediately. If
|
|
69
|
-
your company makes such a claim, your patent license ends
|
|
70
|
-
immediately for work on behalf of your company.
|
|
71
|
-
|
|
72
|
-
## Violations
|
|
73
|
-
|
|
74
|
-
The first time you are notified in writing that you have
|
|
75
|
-
violated any of these terms, or done anything with the software
|
|
76
|
-
not covered by your licenses, your licenses can nonetheless
|
|
77
|
-
continue if you come into full compliance with these terms,
|
|
78
|
-
and take practical steps to correct past violations, within
|
|
79
|
-
32 days of receiving notice. Otherwise, all your licenses
|
|
80
|
-
end immediately.
|
|
81
|
-
|
|
82
|
-
## No Liability
|
|
83
|
-
|
|
84
|
-
***As far as the law allows, the software comes as is, without
|
|
85
|
-
any warranty or condition, and the licensor will not be liable
|
|
86
|
-
to you for any damages arising out of these terms or the use
|
|
87
|
-
or nature of the software, under any kind of legal claim.***
|
|
88
|
-
|
|
89
|
-
## Definitions
|
|
90
|
-
|
|
91
|
-
The **licensor** is the individual or entity offering these
|
|
92
|
-
terms, and the **software** is the software the licensor makes
|
|
93
|
-
available under these terms.
|
|
94
|
-
|
|
95
|
-
**You** refers to the individual or entity agreeing to these
|
|
96
|
-
terms.
|
|
97
|
-
|
|
98
|
-
**Your company** is any legal entity, sole proprietorship,
|
|
99
|
-
or other kind of organization that you work for, plus all
|
|
100
|
-
organizations that have control over, are under the control of,
|
|
101
|
-
or are under common control with that organization. **Control**
|
|
102
|
-
means ownership of substantially all the assets of an entity,
|
|
103
|
-
or the power to direct its management and policies by vote,
|
|
104
|
-
contract, or otherwise. Control can be direct or indirect.
|
|
105
|
-
|
|
106
|
-
**Your licenses** are all the licenses granted to you for the
|
|
107
|
-
software under these terms.
|
|
108
|
-
|
|
109
|
-
**Use** means anything you do with the software requiring one
|
|
110
|
-
of your licenses.
|
|
111
|
-
|
|
112
|
-
**Permitted purpose** means any purpose other than competing
|
|
113
|
-
with the licensor or any product the licensor or its affiliates
|
|
114
|
-
provides using the software.
|
|
115
|
-
|
|
116
|
-
---
|
|
117
|
-
|
|
118
|
-
Required Notice: Copyright (c) 2026 ObjectQL Contributors (https://github.com/objectql)
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ObjectQL Contributors (https://github.com/objectql)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { IObjectQL } from '@objectql/types';
|
|
2
|
+
import { IncomingMessage, ServerResponse } from 'http';
|
|
3
|
+
import { GraphQLSchema } from 'graphql';
|
|
4
|
+
/**
|
|
5
|
+
* Generate GraphQL schema from ObjectQL metadata
|
|
6
|
+
*/
|
|
7
|
+
export declare function generateGraphQLSchema(app: IObjectQL): GraphQLSchema;
|
|
8
|
+
/**
|
|
9
|
+
* Creates a GraphQL HTTP request handler for ObjectQL
|
|
10
|
+
*
|
|
11
|
+
* Endpoints:
|
|
12
|
+
* - POST /api/graphql - GraphQL queries and mutations
|
|
13
|
+
* - GET /api/graphql - GraphQL queries via URL parameters
|
|
14
|
+
*/
|
|
15
|
+
export declare function createGraphQLHandler(app: IObjectQL): (req: IncomingMessage & {
|
|
16
|
+
body?: any;
|
|
17
|
+
}, res: ServerResponse) => Promise<void>;
|
|
@@ -0,0 +1,460 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateGraphQLSchema = generateGraphQLSchema;
|
|
4
|
+
exports.createGraphQLHandler = createGraphQLHandler;
|
|
5
|
+
const server_1 = require("../server");
|
|
6
|
+
const types_1 = require("../types");
|
|
7
|
+
const graphql_1 = require("graphql");
|
|
8
|
+
/**
|
|
9
|
+
* Normalize ObjectQL response to use 'id' instead of '_id'
|
|
10
|
+
*/
|
|
11
|
+
function normalizeId(data) {
|
|
12
|
+
if (!data)
|
|
13
|
+
return data;
|
|
14
|
+
if (Array.isArray(data)) {
|
|
15
|
+
return data.map(item => normalizeId(item));
|
|
16
|
+
}
|
|
17
|
+
if (typeof data === 'object') {
|
|
18
|
+
const normalized = { ...data };
|
|
19
|
+
// Map _id to id if present
|
|
20
|
+
if ('_id' in normalized) {
|
|
21
|
+
normalized.id = normalized._id;
|
|
22
|
+
delete normalized._id;
|
|
23
|
+
}
|
|
24
|
+
// Remove '@type' field as it's not needed in GraphQL
|
|
25
|
+
delete normalized['@type'];
|
|
26
|
+
return normalized;
|
|
27
|
+
}
|
|
28
|
+
return data;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Map ObjectQL field types to GraphQL types
|
|
32
|
+
*/
|
|
33
|
+
function mapFieldTypeToGraphQL(field, isInput = false) {
|
|
34
|
+
const type = field.type;
|
|
35
|
+
switch (type) {
|
|
36
|
+
case 'text':
|
|
37
|
+
case 'textarea':
|
|
38
|
+
case 'markdown':
|
|
39
|
+
case 'html':
|
|
40
|
+
case 'email':
|
|
41
|
+
case 'url':
|
|
42
|
+
case 'phone':
|
|
43
|
+
case 'password':
|
|
44
|
+
return graphql_1.GraphQLString;
|
|
45
|
+
case 'number':
|
|
46
|
+
case 'currency':
|
|
47
|
+
case 'percent':
|
|
48
|
+
return graphql_1.GraphQLFloat;
|
|
49
|
+
case 'auto_number':
|
|
50
|
+
return graphql_1.GraphQLInt;
|
|
51
|
+
case 'boolean':
|
|
52
|
+
return graphql_1.GraphQLBoolean;
|
|
53
|
+
case 'date':
|
|
54
|
+
case 'datetime':
|
|
55
|
+
case 'time':
|
|
56
|
+
return graphql_1.GraphQLString; // ISO 8601 string format
|
|
57
|
+
case 'select':
|
|
58
|
+
// For select fields, we could create an enum type, but for simplicity use String
|
|
59
|
+
return graphql_1.GraphQLString;
|
|
60
|
+
case 'lookup':
|
|
61
|
+
case 'master_detail':
|
|
62
|
+
// For relationships, return ID reference
|
|
63
|
+
return graphql_1.GraphQLString;
|
|
64
|
+
case 'file':
|
|
65
|
+
case 'image':
|
|
66
|
+
// File fields return metadata object (simplified as String for now)
|
|
67
|
+
return graphql_1.GraphQLString;
|
|
68
|
+
case 'object':
|
|
69
|
+
case 'formula':
|
|
70
|
+
case 'summary':
|
|
71
|
+
case 'location':
|
|
72
|
+
case 'vector':
|
|
73
|
+
case 'grid':
|
|
74
|
+
// Return as JSON string
|
|
75
|
+
return graphql_1.GraphQLString;
|
|
76
|
+
default:
|
|
77
|
+
return graphql_1.GraphQLString;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Sanitize field/object names to be valid GraphQL identifiers
|
|
82
|
+
* GraphQL names must match /^[_a-zA-Z][_a-zA-Z0-9]*$/
|
|
83
|
+
*/
|
|
84
|
+
function sanitizeGraphQLName(name) {
|
|
85
|
+
// Replace invalid characters with underscores
|
|
86
|
+
let sanitized = name.replace(/[^_a-zA-Z0-9]/g, '_');
|
|
87
|
+
// Ensure it starts with a letter or underscore
|
|
88
|
+
if (!/^[_a-zA-Z]/.test(sanitized)) {
|
|
89
|
+
sanitized = '_' + sanitized;
|
|
90
|
+
}
|
|
91
|
+
return sanitized;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Generate GraphQL schema from ObjectQL metadata
|
|
95
|
+
*/
|
|
96
|
+
function generateGraphQLSchema(app) {
|
|
97
|
+
const objects = app.metadata.list('object');
|
|
98
|
+
// Validate that there are objects to generate schema from
|
|
99
|
+
if (!objects || objects.length === 0) {
|
|
100
|
+
// Create a minimal schema with a dummy query to avoid GraphQL error
|
|
101
|
+
return new graphql_1.GraphQLSchema({
|
|
102
|
+
query: new graphql_1.GraphQLObjectType({
|
|
103
|
+
name: 'Query',
|
|
104
|
+
fields: {
|
|
105
|
+
_schema: {
|
|
106
|
+
type: graphql_1.GraphQLString,
|
|
107
|
+
description: 'Schema introspection placeholder',
|
|
108
|
+
resolve: () => 'No objects registered in ObjectQL metadata'
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
})
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
const typeMap = {};
|
|
115
|
+
const inputTypeMap = {};
|
|
116
|
+
const deleteResultTypeMap = {};
|
|
117
|
+
// Create a shared ObjectQL server instance to reuse across resolvers
|
|
118
|
+
// This is safe because ObjectQLServer is stateless - it only holds a reference to the app
|
|
119
|
+
// and creates fresh contexts for each request via handle()
|
|
120
|
+
const server = new server_1.ObjectQLServer(app);
|
|
121
|
+
// First pass: Create all object types
|
|
122
|
+
for (const config of objects) {
|
|
123
|
+
const objectName = config.name;
|
|
124
|
+
// Skip if no name or fields defined
|
|
125
|
+
if (!objectName || !config.fields || Object.keys(config.fields).length === 0) {
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
const sanitizedTypeName = sanitizeGraphQLName(objectName.charAt(0).toUpperCase() + objectName.slice(1));
|
|
129
|
+
// Create output type
|
|
130
|
+
const fields = {
|
|
131
|
+
id: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString) }
|
|
132
|
+
};
|
|
133
|
+
for (const [fieldName, fieldConfig] of Object.entries(config.fields)) {
|
|
134
|
+
const sanitizedFieldName = sanitizeGraphQLName(fieldName);
|
|
135
|
+
const gqlType = mapFieldTypeToGraphQL(fieldConfig, false);
|
|
136
|
+
fields[sanitizedFieldName] = {
|
|
137
|
+
type: fieldConfig.required ? new graphql_1.GraphQLNonNull(gqlType) : gqlType,
|
|
138
|
+
description: fieldConfig.label || fieldName
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
typeMap[objectName] = new graphql_1.GraphQLObjectType({
|
|
142
|
+
name: sanitizedTypeName,
|
|
143
|
+
description: config.label || objectName,
|
|
144
|
+
fields
|
|
145
|
+
});
|
|
146
|
+
// Create input type for mutations
|
|
147
|
+
const inputFields = {};
|
|
148
|
+
for (const [fieldName, fieldConfig] of Object.entries(config.fields)) {
|
|
149
|
+
const sanitizedFieldName = sanitizeGraphQLName(fieldName);
|
|
150
|
+
const gqlType = mapFieldTypeToGraphQL(fieldConfig, true);
|
|
151
|
+
inputFields[sanitizedFieldName] = {
|
|
152
|
+
type: gqlType,
|
|
153
|
+
description: fieldConfig.label || fieldName
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
inputTypeMap[objectName] = new graphql_1.GraphQLInputObjectType({
|
|
157
|
+
name: sanitizedTypeName + 'Input',
|
|
158
|
+
description: `Input type for ${config.label || objectName}`,
|
|
159
|
+
fields: inputFields
|
|
160
|
+
});
|
|
161
|
+
// Create delete result type (shared across all delete mutations for this object)
|
|
162
|
+
deleteResultTypeMap[objectName] = new graphql_1.GraphQLObjectType({
|
|
163
|
+
name: 'Delete' + sanitizedTypeName + 'Result',
|
|
164
|
+
fields: {
|
|
165
|
+
id: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString) },
|
|
166
|
+
deleted: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLBoolean) }
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
// Build query root
|
|
171
|
+
const queryFields = {};
|
|
172
|
+
for (const config of objects) {
|
|
173
|
+
const objectName = config.name;
|
|
174
|
+
if (!objectName || !typeMap[objectName])
|
|
175
|
+
continue;
|
|
176
|
+
// Query single record by ID
|
|
177
|
+
queryFields[objectName] = {
|
|
178
|
+
type: typeMap[objectName],
|
|
179
|
+
args: {
|
|
180
|
+
id: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString) }
|
|
181
|
+
},
|
|
182
|
+
resolve: async (_, args) => {
|
|
183
|
+
const result = await server.handle({
|
|
184
|
+
op: 'findOne',
|
|
185
|
+
object: objectName,
|
|
186
|
+
args: args.id
|
|
187
|
+
});
|
|
188
|
+
if (result.error) {
|
|
189
|
+
throw new Error(result.error.message);
|
|
190
|
+
}
|
|
191
|
+
return normalizeId(result);
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
// Query list of records
|
|
195
|
+
// Using 'List' suffix to avoid naming conflicts and handle irregular plurals
|
|
196
|
+
queryFields[objectName + 'List'] = {
|
|
197
|
+
type: new graphql_1.GraphQLList(typeMap[objectName]),
|
|
198
|
+
args: {
|
|
199
|
+
limit: { type: graphql_1.GraphQLInt },
|
|
200
|
+
skip: { type: graphql_1.GraphQLInt },
|
|
201
|
+
filters: { type: graphql_1.GraphQLString }, // JSON string
|
|
202
|
+
fields: { type: new graphql_1.GraphQLList(graphql_1.GraphQLString) },
|
|
203
|
+
sort: { type: graphql_1.GraphQLString } // JSON string
|
|
204
|
+
},
|
|
205
|
+
resolve: async (_, args) => {
|
|
206
|
+
const queryArgs = {};
|
|
207
|
+
if (args.limit)
|
|
208
|
+
queryArgs.limit = args.limit;
|
|
209
|
+
if (args.skip)
|
|
210
|
+
queryArgs.skip = args.skip;
|
|
211
|
+
if (args.fields)
|
|
212
|
+
queryArgs.fields = args.fields;
|
|
213
|
+
if (args.filters) {
|
|
214
|
+
try {
|
|
215
|
+
queryArgs.filters = JSON.parse(args.filters);
|
|
216
|
+
}
|
|
217
|
+
catch (e) {
|
|
218
|
+
throw new Error('Invalid filters JSON');
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
if (args.sort) {
|
|
222
|
+
try {
|
|
223
|
+
queryArgs.sort = JSON.parse(args.sort);
|
|
224
|
+
}
|
|
225
|
+
catch (e) {
|
|
226
|
+
throw new Error('Invalid sort JSON');
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
const result = await server.handle({
|
|
230
|
+
op: 'find',
|
|
231
|
+
object: objectName,
|
|
232
|
+
args: queryArgs
|
|
233
|
+
});
|
|
234
|
+
if (result.error) {
|
|
235
|
+
throw new Error(result.error.message);
|
|
236
|
+
}
|
|
237
|
+
return normalizeId(result.items || []);
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
const queryType = new graphql_1.GraphQLObjectType({
|
|
242
|
+
name: 'Query',
|
|
243
|
+
fields: queryFields
|
|
244
|
+
});
|
|
245
|
+
// Build mutation root
|
|
246
|
+
const mutationFields = {};
|
|
247
|
+
for (const config of objects) {
|
|
248
|
+
const objectName = config.name;
|
|
249
|
+
if (!objectName || !typeMap[objectName] || !inputTypeMap[objectName])
|
|
250
|
+
continue;
|
|
251
|
+
const capitalizedName = sanitizeGraphQLName(objectName.charAt(0).toUpperCase() + objectName.slice(1));
|
|
252
|
+
// Create mutation
|
|
253
|
+
mutationFields['create' + capitalizedName] = {
|
|
254
|
+
type: typeMap[objectName],
|
|
255
|
+
args: {
|
|
256
|
+
input: { type: new graphql_1.GraphQLNonNull(inputTypeMap[objectName]) }
|
|
257
|
+
},
|
|
258
|
+
resolve: async (_, args) => {
|
|
259
|
+
const result = await server.handle({
|
|
260
|
+
op: 'create',
|
|
261
|
+
object: objectName,
|
|
262
|
+
args: args.input
|
|
263
|
+
});
|
|
264
|
+
if (result.error) {
|
|
265
|
+
throw new Error(result.error.message);
|
|
266
|
+
}
|
|
267
|
+
return normalizeId(result);
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
// Update mutation
|
|
271
|
+
mutationFields['update' + capitalizedName] = {
|
|
272
|
+
type: typeMap[objectName],
|
|
273
|
+
args: {
|
|
274
|
+
id: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString) },
|
|
275
|
+
input: { type: new graphql_1.GraphQLNonNull(inputTypeMap[objectName]) }
|
|
276
|
+
},
|
|
277
|
+
resolve: async (_, args) => {
|
|
278
|
+
const result = await server.handle({
|
|
279
|
+
op: 'update',
|
|
280
|
+
object: objectName,
|
|
281
|
+
args: {
|
|
282
|
+
id: args.id,
|
|
283
|
+
data: args.input
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
if (result.error) {
|
|
287
|
+
throw new Error(result.error.message);
|
|
288
|
+
}
|
|
289
|
+
return normalizeId(result);
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
// Delete mutation - use shared delete result type
|
|
293
|
+
mutationFields['delete' + capitalizedName] = {
|
|
294
|
+
type: deleteResultTypeMap[objectName],
|
|
295
|
+
args: {
|
|
296
|
+
id: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString) }
|
|
297
|
+
},
|
|
298
|
+
resolve: async (_, args) => {
|
|
299
|
+
const result = await server.handle({
|
|
300
|
+
op: 'delete',
|
|
301
|
+
object: objectName,
|
|
302
|
+
args: { id: args.id }
|
|
303
|
+
});
|
|
304
|
+
if (result.error) {
|
|
305
|
+
throw new Error(result.error.message);
|
|
306
|
+
}
|
|
307
|
+
return result;
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
const mutationType = new graphql_1.GraphQLObjectType({
|
|
312
|
+
name: 'Mutation',
|
|
313
|
+
fields: mutationFields
|
|
314
|
+
});
|
|
315
|
+
return new graphql_1.GraphQLSchema({
|
|
316
|
+
query: queryType,
|
|
317
|
+
mutation: mutationType
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Parse GraphQL request body
|
|
322
|
+
*/
|
|
323
|
+
function readBody(req) {
|
|
324
|
+
return new Promise((resolve, reject) => {
|
|
325
|
+
let body = '';
|
|
326
|
+
req.on('data', chunk => body += chunk.toString());
|
|
327
|
+
req.on('end', () => {
|
|
328
|
+
if (!body)
|
|
329
|
+
return resolve({});
|
|
330
|
+
try {
|
|
331
|
+
resolve(JSON.parse(body));
|
|
332
|
+
}
|
|
333
|
+
catch (e) {
|
|
334
|
+
reject(new Error('Invalid JSON'));
|
|
335
|
+
}
|
|
336
|
+
});
|
|
337
|
+
req.on('error', reject);
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Send JSON response
|
|
342
|
+
*/
|
|
343
|
+
function sendJSON(res, statusCode, data) {
|
|
344
|
+
res.setHeader('Content-Type', 'application/json');
|
|
345
|
+
res.statusCode = statusCode;
|
|
346
|
+
res.end(JSON.stringify(data));
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Creates a GraphQL HTTP request handler for ObjectQL
|
|
350
|
+
*
|
|
351
|
+
* Endpoints:
|
|
352
|
+
* - POST /api/graphql - GraphQL queries and mutations
|
|
353
|
+
* - GET /api/graphql - GraphQL queries via URL parameters
|
|
354
|
+
*/
|
|
355
|
+
function createGraphQLHandler(app) {
|
|
356
|
+
// Generate schema once - Note: Schema is static after handler creation.
|
|
357
|
+
// If metadata changes at runtime, create a new handler or regenerate the schema.
|
|
358
|
+
const schema = generateGraphQLSchema(app);
|
|
359
|
+
return async (req, res) => {
|
|
360
|
+
try {
|
|
361
|
+
// CORS headers
|
|
362
|
+
const requestOrigin = req.headers.origin;
|
|
363
|
+
const configuredOrigin = process.env.OBJECTQL_CORS_ORIGIN;
|
|
364
|
+
const isProduction = process.env.NODE_ENV === 'production';
|
|
365
|
+
if (!isProduction) {
|
|
366
|
+
res.setHeader('Access-Control-Allow-Origin', configuredOrigin || '*');
|
|
367
|
+
}
|
|
368
|
+
else if (configuredOrigin && (!requestOrigin || requestOrigin === configuredOrigin)) {
|
|
369
|
+
res.setHeader('Access-Control-Allow-Origin', configuredOrigin);
|
|
370
|
+
}
|
|
371
|
+
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS');
|
|
372
|
+
res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization');
|
|
373
|
+
if (req.method === 'OPTIONS') {
|
|
374
|
+
res.statusCode = 200;
|
|
375
|
+
res.end();
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
378
|
+
const url = req.url || '';
|
|
379
|
+
const method = req.method || 'POST';
|
|
380
|
+
if (method !== 'GET' && method !== 'POST') {
|
|
381
|
+
sendJSON(res, 405, {
|
|
382
|
+
errors: [{
|
|
383
|
+
message: 'Method not allowed. Use GET or POST.'
|
|
384
|
+
}]
|
|
385
|
+
});
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
let query = '';
|
|
389
|
+
let variables = null;
|
|
390
|
+
let operationName = null;
|
|
391
|
+
if (method === 'GET') {
|
|
392
|
+
// Parse query string for GET requests
|
|
393
|
+
const urlObj = new URL(url, `http://${req.headers.host || 'localhost'}`);
|
|
394
|
+
query = urlObj.searchParams.get('query') || '';
|
|
395
|
+
const varsParam = urlObj.searchParams.get('variables');
|
|
396
|
+
if (varsParam) {
|
|
397
|
+
try {
|
|
398
|
+
variables = JSON.parse(varsParam);
|
|
399
|
+
}
|
|
400
|
+
catch (e) {
|
|
401
|
+
sendJSON(res, 400, {
|
|
402
|
+
errors: [{
|
|
403
|
+
message: 'Invalid variables JSON'
|
|
404
|
+
}]
|
|
405
|
+
});
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
operationName = urlObj.searchParams.get('operationName');
|
|
410
|
+
}
|
|
411
|
+
else {
|
|
412
|
+
// Parse body for POST requests
|
|
413
|
+
const body = req.body || await readBody(req);
|
|
414
|
+
query = body.query || '';
|
|
415
|
+
variables = body.variables || null;
|
|
416
|
+
operationName = body.operationName || null;
|
|
417
|
+
}
|
|
418
|
+
if (!query) {
|
|
419
|
+
sendJSON(res, 400, {
|
|
420
|
+
errors: [{
|
|
421
|
+
message: 'Must provide query string'
|
|
422
|
+
}]
|
|
423
|
+
});
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
// Execute GraphQL query
|
|
427
|
+
const result = await (0, graphql_1.graphql)({
|
|
428
|
+
schema,
|
|
429
|
+
source: query,
|
|
430
|
+
variableValues: variables,
|
|
431
|
+
operationName,
|
|
432
|
+
contextValue: { app }
|
|
433
|
+
});
|
|
434
|
+
sendJSON(res, 200, result);
|
|
435
|
+
}
|
|
436
|
+
catch (e) {
|
|
437
|
+
console.error('[GraphQL Handler] Error:', e);
|
|
438
|
+
const errorResponse = {
|
|
439
|
+
errors: [{
|
|
440
|
+
message: 'Internal server error',
|
|
441
|
+
extensions: {
|
|
442
|
+
code: types_1.ErrorCode.INTERNAL_ERROR
|
|
443
|
+
}
|
|
444
|
+
}]
|
|
445
|
+
};
|
|
446
|
+
// In non-production environments, include additional error details to aid debugging
|
|
447
|
+
if (typeof process !== 'undefined' &&
|
|
448
|
+
process.env &&
|
|
449
|
+
process.env.NODE_ENV !== 'production') {
|
|
450
|
+
const firstError = errorResponse.errors[0];
|
|
451
|
+
firstError.extensions.debug = {
|
|
452
|
+
message: e && typeof e.message === 'string' ? e.message : undefined,
|
|
453
|
+
stack: e && typeof e.stack === 'string' ? e.stack : undefined
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
sendJSON(res, 500, errorResponse);
|
|
457
|
+
}
|
|
458
|
+
};
|
|
459
|
+
}
|
|
460
|
+
//# sourceMappingURL=graphql.js.map
|
|
@@ -0,0 +1 @@
|
|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