@cedarjs/internal 3.0.0-canary.13596 → 3.0.0-canary.13597
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/dist/cjs/generate/graphqlCodeGen.d.ts.map +1 -1
- package/dist/cjs/generate/graphqlCodeGen.js +62 -22
- package/dist/cjs/generate/graphqlSchema.d.ts.map +1 -1
- package/dist/cjs/generate/graphqlSchema.js +9 -14
- package/dist/cjs/project.d.ts.map +1 -1
- package/dist/cjs/project.js +15 -1
- package/dist/generate/graphqlCodeGen.d.ts.map +1 -1
- package/dist/generate/graphqlCodeGen.js +59 -19
- package/dist/generate/graphqlSchema.d.ts.map +1 -1
- package/dist/generate/graphqlSchema.js +10 -15
- package/dist/project.d.ts.map +1 -1
- package/dist/project.js +15 -1
- package/package.json +8 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphqlCodeGen.d.ts","sourceRoot":"","sources":["../../../src/generate/graphqlCodeGen.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"graphqlCodeGen.d.ts","sourceRoot":"","sources":["../../../src/generate/graphqlCodeGen.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAkB9D,KAAK,aAAa,GAAG;IACnB,YAAY,EAAE,MAAM,EAAE,CAAA;IACtB,MAAM,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAE,EAAE,CAAA;CAC9C,CAAA;AAED,eAAO,MAAM,yBAAyB,QAAa,OAAO,CAAC,aAAa,CAmFvE,CAAA;AAED,eAAO,MAAM,yBAAyB,QAAa,OAAO,CAAC,aAAa,CA0DvE,CAAA;AAmCD,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM;SACD,MAAM;GAQ5D;AA4KD,eAAO,MAAM,iBAAiB,4RAe7B,CAAA"}
|
|
@@ -35,7 +35,8 @@ __export(graphqlCodeGen_exports, {
|
|
|
35
35
|
});
|
|
36
36
|
module.exports = __toCommonJS(graphqlCodeGen_exports);
|
|
37
37
|
var import_node_fs = __toESM(require("node:fs"), 1);
|
|
38
|
-
var
|
|
38
|
+
var import_node_path = __toESM(require("node:path"), 1);
|
|
39
|
+
var import_node_url = require("node:url");
|
|
39
40
|
var addPlugin = __toESM(require("@graphql-codegen/add"), 1);
|
|
40
41
|
var import_cli = require("@graphql-codegen/cli");
|
|
41
42
|
var import_core = require("@graphql-codegen/core");
|
|
@@ -76,7 +77,7 @@ const generateTypeDefGraphQLApi = async () => {
|
|
|
76
77
|
errors
|
|
77
78
|
};
|
|
78
79
|
}
|
|
79
|
-
const filename =
|
|
80
|
+
const filename = import_node_path.default.join((0, import_project_config.getPaths)().api.types, "graphql.d.ts");
|
|
80
81
|
const prismaModels = await getPrismaModels();
|
|
81
82
|
const prismaImports = Object.keys(prismaModels).map((key) => {
|
|
82
83
|
return `${key} as Prisma${key}`;
|
|
@@ -128,7 +129,7 @@ const generateTypeDefGraphQLApi = async () => {
|
|
|
128
129
|
}
|
|
129
130
|
};
|
|
130
131
|
const generateTypeDefGraphQLWeb = async () => {
|
|
131
|
-
const filename =
|
|
132
|
+
const filename = import_node_path.default.join((0, import_project_config.getPaths)().web.types, "graphql.d.ts");
|
|
132
133
|
const options = getLoadDocumentsOptions(filename);
|
|
133
134
|
const documentsGlob = "./web/src/**/!(*.d).{ts,tsx,js,jsx}";
|
|
134
135
|
let documents;
|
|
@@ -181,13 +182,14 @@ async function runCodegenGraphQL(documents, extraPlugins, filename, side) {
|
|
|
181
182
|
const userCodegenConfig = await (0, import_cli.loadCodegenConfig)({
|
|
182
183
|
configFilePath: (0, import_project_config.getPaths)().base
|
|
183
184
|
});
|
|
185
|
+
const pluginConfig = await getPluginConfig(side);
|
|
184
186
|
const mergedConfig = {
|
|
185
|
-
...
|
|
187
|
+
...pluginConfig,
|
|
186
188
|
...userCodegenConfig?.config?.config
|
|
187
189
|
};
|
|
188
190
|
const options = getCodegenOptions(documents, mergedConfig, extraPlugins);
|
|
189
191
|
const output = await (0, import_core.codegen)(options);
|
|
190
|
-
import_node_fs.default.mkdirSync(
|
|
192
|
+
import_node_fs.default.mkdirSync(import_node_path.default.dirname(filename), { recursive: true });
|
|
191
193
|
import_node_fs.default.writeFileSync(filename, output);
|
|
192
194
|
return [filename];
|
|
193
195
|
}
|
|
@@ -200,26 +202,64 @@ function getLoadDocumentsOptions(filename) {
|
|
|
200
202
|
};
|
|
201
203
|
return loadTypedefsConfig;
|
|
202
204
|
}
|
|
203
|
-
async function
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
205
|
+
async function importGeneratedPrismaClient() {
|
|
206
|
+
const cacheBuster = `?t=${Date.now()}`;
|
|
207
|
+
const prismaClientPath = await (0, import_project_config.resolveGeneratedPrismaClient)({
|
|
208
|
+
mustExist: true
|
|
209
|
+
});
|
|
210
|
+
const fileUrl = (0, import_node_url.pathToFileURL)(prismaClientPath).href + cacheBuster;
|
|
211
|
+
const freshPrisma = await import(fileUrl);
|
|
212
|
+
return freshPrisma;
|
|
213
|
+
}
|
|
214
|
+
function isModelNameRecord(value) {
|
|
215
|
+
if (typeof value !== "object" || value === null) {
|
|
216
|
+
return false;
|
|
217
|
+
}
|
|
218
|
+
return Object.values(value).every((entry) => typeof entry === "string");
|
|
219
|
+
}
|
|
220
|
+
function getModelName(value) {
|
|
221
|
+
if (typeof value !== "object" || value === null) {
|
|
222
|
+
return null;
|
|
213
223
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
224
|
+
const valueRecord = value;
|
|
225
|
+
if (isModelNameRecord(valueRecord.ModelName)) {
|
|
226
|
+
return valueRecord.ModelName;
|
|
227
|
+
}
|
|
228
|
+
if (isModelNameRecord(valueRecord.Prisma?.ModelName)) {
|
|
229
|
+
return valueRecord.Prisma.ModelName;
|
|
230
|
+
}
|
|
231
|
+
if ("default" in valueRecord) {
|
|
232
|
+
return getModelName(valueRecord.default);
|
|
233
|
+
}
|
|
234
|
+
return null;
|
|
235
|
+
}
|
|
236
|
+
async function getPrismaClient() {
|
|
237
|
+
try {
|
|
238
|
+
const localPrisma = await importGeneratedPrismaClient();
|
|
239
|
+
const modelName = getModelName(localPrisma);
|
|
240
|
+
if (modelName) {
|
|
241
|
+
return { ModelName: modelName };
|
|
220
242
|
}
|
|
243
|
+
} catch {
|
|
244
|
+
}
|
|
245
|
+
try {
|
|
246
|
+
const packagePrisma = await import("@prisma/client");
|
|
247
|
+
const modelName = getModelName(packagePrisma);
|
|
248
|
+
if (modelName) {
|
|
249
|
+
return { ModelName: modelName };
|
|
250
|
+
}
|
|
251
|
+
} catch {
|
|
252
|
+
}
|
|
253
|
+
import_execa.default.sync("yarn", ["cedar", "prisma", "generate"]);
|
|
254
|
+
try {
|
|
255
|
+
const freshPrisma = await importGeneratedPrismaClient();
|
|
256
|
+
const modelName = getModelName(freshPrisma);
|
|
257
|
+
if (modelName) {
|
|
258
|
+
return { ModelName: modelName };
|
|
259
|
+
}
|
|
260
|
+
} catch {
|
|
221
261
|
}
|
|
222
|
-
return
|
|
262
|
+
return { ModelName: {} };
|
|
223
263
|
}
|
|
224
264
|
async function getPrismaModels() {
|
|
225
265
|
const localPrisma = await getPrismaClient();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphqlSchema.d.ts","sourceRoot":"","sources":["../../../src/generate/graphqlSchema.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"graphqlSchema.d.ts","sourceRoot":"","sources":["../../../src/generate/graphqlSchema.ts"],"names":[],"mappings":"AAyBA,eAAO,MAAM,qBAAqB;;;iBA2DP,MAAM;eAAS,OAAO;;EA2EhD,CAAA"}
|
|
@@ -36,16 +36,14 @@ var import_core = require("@graphql-codegen/core");
|
|
|
36
36
|
var schemaAstPlugin = __toESM(require("@graphql-codegen/schema-ast"), 1);
|
|
37
37
|
var import_code_file_loader = require("@graphql-tools/code-file-loader");
|
|
38
38
|
var import_load = require("@graphql-tools/load");
|
|
39
|
-
var import_internals = __toESM(require("@prisma/internals"), 1);
|
|
40
39
|
var import_ansis = __toESM(require("ansis"), 1);
|
|
41
40
|
var import_graphql = require("graphql");
|
|
42
41
|
var import_termi_link = require("termi-link");
|
|
43
42
|
var import_graphql_server = require("@cedarjs/graphql-server");
|
|
44
43
|
var import_project_config = require("@cedarjs/project-config");
|
|
45
|
-
const { getSchemaWithPath } = import_internals.default;
|
|
46
44
|
const generateGraphQLSchema = async () => {
|
|
47
|
-
const
|
|
48
|
-
const
|
|
45
|
+
const cedarPaths = (0, import_project_config.getPaths)();
|
|
46
|
+
const cedarConfig = (0, import_project_config.getConfig)();
|
|
49
47
|
const schemaPointerMap = {
|
|
50
48
|
[(0, import_graphql.print)(import_graphql_server.rootSchema.schema)]: {},
|
|
51
49
|
"graphql/**/*.sdl.{js,ts}": {},
|
|
@@ -57,7 +55,7 @@ const generateGraphQLSchema = async () => {
|
|
|
57
55
|
"!subscriptions/**/*.spec.{js,ts}": {}
|
|
58
56
|
};
|
|
59
57
|
for (const [name, schema] of Object.entries(import_graphql_server.rootSchema.scalarSchemas)) {
|
|
60
|
-
if (
|
|
58
|
+
if (cedarConfig.graphql.includeScalars[name]) {
|
|
61
59
|
schemaPointerMap[(0, import_graphql.print)(schema)] = {};
|
|
62
60
|
}
|
|
63
61
|
}
|
|
@@ -76,10 +74,10 @@ const generateGraphQLSchema = async () => {
|
|
|
76
74
|
sort: true,
|
|
77
75
|
convertExtensions: true,
|
|
78
76
|
includeSources: true,
|
|
79
|
-
cwd:
|
|
77
|
+
cwd: cedarPaths.api.src,
|
|
80
78
|
schema: Object.keys(schemaPointerMap),
|
|
81
79
|
generates: {
|
|
82
|
-
[
|
|
80
|
+
[cedarPaths.generated.schema]: {
|
|
83
81
|
plugins: ["schema-ast"]
|
|
84
82
|
}
|
|
85
83
|
},
|
|
@@ -96,10 +94,7 @@ const generateGraphQLSchema = async () => {
|
|
|
96
94
|
if (e instanceof Error) {
|
|
97
95
|
const match = e.message.match(/Unknown type: "(\w+)"/);
|
|
98
96
|
const name = match?.[1];
|
|
99
|
-
const
|
|
100
|
-
redwoodProjectPaths.api.prismaConfig
|
|
101
|
-
);
|
|
102
|
-
const result = await getSchemaWithPath(schemaPath);
|
|
97
|
+
const result = await (0, import_project_config.getPrismaSchemas)();
|
|
103
98
|
const schemaPrisma = result.schemas.map(([, content]) => content).join("\n");
|
|
104
99
|
const errorObject = {
|
|
105
100
|
message: `Schema loading failed. ${e.message}`,
|
|
@@ -139,14 +134,14 @@ const generateGraphQLSchema = async () => {
|
|
|
139
134
|
pluginMap: { "schema-ast": schemaAstPlugin },
|
|
140
135
|
schema: {},
|
|
141
136
|
schemaAst: loadedSchema,
|
|
142
|
-
filename:
|
|
137
|
+
filename: cedarPaths.generated.schema,
|
|
143
138
|
documents: []
|
|
144
139
|
};
|
|
145
140
|
if (loadedSchema) {
|
|
146
141
|
try {
|
|
147
142
|
const schema = await (0, import_core.codegen)(options);
|
|
148
|
-
import_node_fs.default.writeFileSync(
|
|
149
|
-
return { schemaPath:
|
|
143
|
+
import_node_fs.default.writeFileSync(cedarPaths.generated.schema, schema);
|
|
144
|
+
return { schemaPath: cedarPaths.generated.schema, errors };
|
|
150
145
|
} catch (e) {
|
|
151
146
|
errors.push({
|
|
152
147
|
message: `GraphQL Schema codegen failed`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../src/project.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,YAAY;;;CAuBxB,CAAA;AAED,eAAO,MAAM,mBAAmB,eAM/B,CAAA;AAED,eAAO,MAAM,iBAAiB,eAO7B,CAAA;AAED,eAAO,MAAM,eAAe,eAO3B,CAAA;
|
|
1
|
+
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../src/project.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,YAAY;;;CAuBxB,CAAA;AAED,eAAO,MAAM,mBAAmB,eAM/B,CAAA;AAED,eAAO,MAAM,iBAAiB,eAO7B,CAAA;AAED,eAAO,MAAM,eAAe,eAO3B,CAAA;AAID,eAAO,MAAM,uBAAuB,eAoCnC,CAAA"}
|
package/dist/cjs/project.js
CHANGED
|
@@ -80,7 +80,21 @@ const dbReexportsPrismaClient = () => {
|
|
|
80
80
|
return false;
|
|
81
81
|
}
|
|
82
82
|
const content = import_node_fs.default.readFileSync(dbPath, "utf-8");
|
|
83
|
-
|
|
83
|
+
const prismaClientImportMatch = content.match(
|
|
84
|
+
/import\s+{[^}]*\bPrismaClient\b[^}]*}\s+from\s+['"](.*?)['"]/
|
|
85
|
+
);
|
|
86
|
+
const prismaClientLocation = prismaClientImportMatch?.[1];
|
|
87
|
+
if (!prismaClientLocation) {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
return new RegExp(
|
|
91
|
+
// @ts-expect-error - old types. This is supported in Node 24, which is the
|
|
92
|
+
// minimum supported version of Node for CedarJS.
|
|
93
|
+
// RegExp.escape has been added to the newer ES2025 target, but I'm not
|
|
94
|
+
// ready to change that just yet
|
|
95
|
+
// https://github.com/microsoft/TypeScript/pull/63046
|
|
96
|
+
`export \\* from ['"]${RegExp.escape(prismaClientLocation)}['"]`
|
|
97
|
+
).test(content);
|
|
84
98
|
};
|
|
85
99
|
// Annotate the CommonJS export names for ESM import in node:
|
|
86
100
|
0 && (module.exports = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphqlCodeGen.d.ts","sourceRoot":"","sources":["../../src/generate/graphqlCodeGen.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"graphqlCodeGen.d.ts","sourceRoot":"","sources":["../../src/generate/graphqlCodeGen.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAkB9D,KAAK,aAAa,GAAG;IACnB,YAAY,EAAE,MAAM,EAAE,CAAA;IACtB,MAAM,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAE,EAAE,CAAA;CAC9C,CAAA;AAED,eAAO,MAAM,yBAAyB,QAAa,OAAO,CAAC,aAAa,CAmFvE,CAAA;AAED,eAAO,MAAM,yBAAyB,QAAa,OAAO,CAAC,aAAa,CA0DvE,CAAA;AAmCD,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM;SACD,MAAM;GAQ5D;AA4KD,eAAO,MAAM,iBAAiB,4RAe7B,CAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
|
-
import path from "path";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { pathToFileURL } from "node:url";
|
|
3
4
|
import * as addPlugin from "@graphql-codegen/add";
|
|
4
5
|
import { loadCodegenConfig } from "@graphql-codegen/cli";
|
|
5
6
|
import { codegen } from "@graphql-codegen/core";
|
|
@@ -149,8 +150,9 @@ async function runCodegenGraphQL(documents, extraPlugins, filename, side) {
|
|
|
149
150
|
const userCodegenConfig = await loadCodegenConfig({
|
|
150
151
|
configFilePath: getPaths().base
|
|
151
152
|
});
|
|
153
|
+
const pluginConfig = await getPluginConfig(side);
|
|
152
154
|
const mergedConfig = {
|
|
153
|
-
...
|
|
155
|
+
...pluginConfig,
|
|
154
156
|
...userCodegenConfig?.config?.config
|
|
155
157
|
};
|
|
156
158
|
const options = getCodegenOptions(documents, mergedConfig, extraPlugins);
|
|
@@ -168,26 +170,64 @@ function getLoadDocumentsOptions(filename) {
|
|
|
168
170
|
};
|
|
169
171
|
return loadTypedefsConfig;
|
|
170
172
|
}
|
|
171
|
-
async function
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
173
|
+
async function importGeneratedPrismaClient() {
|
|
174
|
+
const cacheBuster = `?t=${Date.now()}`;
|
|
175
|
+
const prismaClientPath = await resolveGeneratedPrismaClient({
|
|
176
|
+
mustExist: true
|
|
177
|
+
});
|
|
178
|
+
const fileUrl = pathToFileURL(prismaClientPath).href + cacheBuster;
|
|
179
|
+
const freshPrisma = await import(fileUrl);
|
|
180
|
+
return freshPrisma;
|
|
181
|
+
}
|
|
182
|
+
function isModelNameRecord(value) {
|
|
183
|
+
if (typeof value !== "object" || value === null) {
|
|
184
|
+
return false;
|
|
185
|
+
}
|
|
186
|
+
return Object.values(value).every((entry) => typeof entry === "string");
|
|
187
|
+
}
|
|
188
|
+
function getModelName(value) {
|
|
189
|
+
if (typeof value !== "object" || value === null) {
|
|
190
|
+
return null;
|
|
181
191
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
192
|
+
const valueRecord = value;
|
|
193
|
+
if (isModelNameRecord(valueRecord.ModelName)) {
|
|
194
|
+
return valueRecord.ModelName;
|
|
195
|
+
}
|
|
196
|
+
if (isModelNameRecord(valueRecord.Prisma?.ModelName)) {
|
|
197
|
+
return valueRecord.Prisma.ModelName;
|
|
198
|
+
}
|
|
199
|
+
if ("default" in valueRecord) {
|
|
200
|
+
return getModelName(valueRecord.default);
|
|
201
|
+
}
|
|
202
|
+
return null;
|
|
203
|
+
}
|
|
204
|
+
async function getPrismaClient() {
|
|
205
|
+
try {
|
|
206
|
+
const localPrisma = await importGeneratedPrismaClient();
|
|
207
|
+
const modelName = getModelName(localPrisma);
|
|
208
|
+
if (modelName) {
|
|
209
|
+
return { ModelName: modelName };
|
|
188
210
|
}
|
|
211
|
+
} catch {
|
|
212
|
+
}
|
|
213
|
+
try {
|
|
214
|
+
const packagePrisma = await import("@prisma/client");
|
|
215
|
+
const modelName = getModelName(packagePrisma);
|
|
216
|
+
if (modelName) {
|
|
217
|
+
return { ModelName: modelName };
|
|
218
|
+
}
|
|
219
|
+
} catch {
|
|
220
|
+
}
|
|
221
|
+
execa.sync("yarn", ["cedar", "prisma", "generate"]);
|
|
222
|
+
try {
|
|
223
|
+
const freshPrisma = await importGeneratedPrismaClient();
|
|
224
|
+
const modelName = getModelName(freshPrisma);
|
|
225
|
+
if (modelName) {
|
|
226
|
+
return { ModelName: modelName };
|
|
227
|
+
}
|
|
228
|
+
} catch {
|
|
189
229
|
}
|
|
190
|
-
return
|
|
230
|
+
return { ModelName: {} };
|
|
191
231
|
}
|
|
192
232
|
async function getPrismaModels() {
|
|
193
233
|
const localPrisma = await getPrismaClient();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphqlSchema.d.ts","sourceRoot":"","sources":["../../src/generate/graphqlSchema.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"graphqlSchema.d.ts","sourceRoot":"","sources":["../../src/generate/graphqlSchema.ts"],"names":[],"mappings":"AAyBA,eAAO,MAAM,qBAAqB;;;iBA2DP,MAAM;eAAS,OAAO;;EA2EhD,CAAA"}
|
|
@@ -3,7 +3,6 @@ import { codegen } from "@graphql-codegen/core";
|
|
|
3
3
|
import * as schemaAstPlugin from "@graphql-codegen/schema-ast";
|
|
4
4
|
import { CodeFileLoader } from "@graphql-tools/code-file-loader";
|
|
5
5
|
import { loadSchema } from "@graphql-tools/load";
|
|
6
|
-
import prismaInternals from "@prisma/internals";
|
|
7
6
|
import ansis from "ansis";
|
|
8
7
|
import { print } from "graphql";
|
|
9
8
|
import { terminalLink } from "termi-link";
|
|
@@ -12,12 +11,11 @@ import {
|
|
|
12
11
|
getPaths,
|
|
13
12
|
getConfig,
|
|
14
13
|
resolveFile,
|
|
15
|
-
|
|
14
|
+
getPrismaSchemas
|
|
16
15
|
} from "@cedarjs/project-config";
|
|
17
|
-
const { getSchemaWithPath } = prismaInternals;
|
|
18
16
|
const generateGraphQLSchema = async () => {
|
|
19
|
-
const
|
|
20
|
-
const
|
|
17
|
+
const cedarPaths = getPaths();
|
|
18
|
+
const cedarConfig = getConfig();
|
|
21
19
|
const schemaPointerMap = {
|
|
22
20
|
[print(rootSchema.schema)]: {},
|
|
23
21
|
"graphql/**/*.sdl.{js,ts}": {},
|
|
@@ -29,7 +27,7 @@ const generateGraphQLSchema = async () => {
|
|
|
29
27
|
"!subscriptions/**/*.spec.{js,ts}": {}
|
|
30
28
|
};
|
|
31
29
|
for (const [name, schema] of Object.entries(rootSchema.scalarSchemas)) {
|
|
32
|
-
if (
|
|
30
|
+
if (cedarConfig.graphql.includeScalars[name]) {
|
|
33
31
|
schemaPointerMap[print(schema)] = {};
|
|
34
32
|
}
|
|
35
33
|
}
|
|
@@ -48,10 +46,10 @@ const generateGraphQLSchema = async () => {
|
|
|
48
46
|
sort: true,
|
|
49
47
|
convertExtensions: true,
|
|
50
48
|
includeSources: true,
|
|
51
|
-
cwd:
|
|
49
|
+
cwd: cedarPaths.api.src,
|
|
52
50
|
schema: Object.keys(schemaPointerMap),
|
|
53
51
|
generates: {
|
|
54
|
-
[
|
|
52
|
+
[cedarPaths.generated.schema]: {
|
|
55
53
|
plugins: ["schema-ast"]
|
|
56
54
|
}
|
|
57
55
|
},
|
|
@@ -68,10 +66,7 @@ const generateGraphQLSchema = async () => {
|
|
|
68
66
|
if (e instanceof Error) {
|
|
69
67
|
const match = e.message.match(/Unknown type: "(\w+)"/);
|
|
70
68
|
const name = match?.[1];
|
|
71
|
-
const
|
|
72
|
-
redwoodProjectPaths.api.prismaConfig
|
|
73
|
-
);
|
|
74
|
-
const result = await getSchemaWithPath(schemaPath);
|
|
69
|
+
const result = await getPrismaSchemas();
|
|
75
70
|
const schemaPrisma = result.schemas.map(([, content]) => content).join("\n");
|
|
76
71
|
const errorObject = {
|
|
77
72
|
message: `Schema loading failed. ${e.message}`,
|
|
@@ -111,14 +106,14 @@ const generateGraphQLSchema = async () => {
|
|
|
111
106
|
pluginMap: { "schema-ast": schemaAstPlugin },
|
|
112
107
|
schema: {},
|
|
113
108
|
schemaAst: loadedSchema,
|
|
114
|
-
filename:
|
|
109
|
+
filename: cedarPaths.generated.schema,
|
|
115
110
|
documents: []
|
|
116
111
|
};
|
|
117
112
|
if (loadedSchema) {
|
|
118
113
|
try {
|
|
119
114
|
const schema = await codegen(options);
|
|
120
|
-
fs.writeFileSync(
|
|
121
|
-
return { schemaPath:
|
|
115
|
+
fs.writeFileSync(cedarPaths.generated.schema, schema);
|
|
116
|
+
return { schemaPath: cedarPaths.generated.schema, errors };
|
|
122
117
|
} catch (e) {
|
|
123
118
|
errors.push({
|
|
124
119
|
message: `GraphQL Schema codegen failed`,
|
package/dist/project.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../src/project.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,YAAY;;;CAuBxB,CAAA;AAED,eAAO,MAAM,mBAAmB,eAM/B,CAAA;AAED,eAAO,MAAM,iBAAiB,eAO7B,CAAA;AAED,eAAO,MAAM,eAAe,eAO3B,CAAA;
|
|
1
|
+
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../src/project.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,YAAY;;;CAuBxB,CAAA;AAED,eAAO,MAAM,mBAAmB,eAM/B,CAAA;AAED,eAAO,MAAM,iBAAiB,eAO7B,CAAA;AAED,eAAO,MAAM,eAAe,eAO3B,CAAA;AAID,eAAO,MAAM,uBAAuB,eAoCnC,CAAA"}
|
package/dist/project.js
CHANGED
|
@@ -43,7 +43,21 @@ const dbReexportsPrismaClient = () => {
|
|
|
43
43
|
return false;
|
|
44
44
|
}
|
|
45
45
|
const content = fs.readFileSync(dbPath, "utf-8");
|
|
46
|
-
|
|
46
|
+
const prismaClientImportMatch = content.match(
|
|
47
|
+
/import\s+{[^}]*\bPrismaClient\b[^}]*}\s+from\s+['"](.*?)['"]/
|
|
48
|
+
);
|
|
49
|
+
const prismaClientLocation = prismaClientImportMatch?.[1];
|
|
50
|
+
if (!prismaClientLocation) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
return new RegExp(
|
|
54
|
+
// @ts-expect-error - old types. This is supported in Node 24, which is the
|
|
55
|
+
// minimum supported version of Node for CedarJS.
|
|
56
|
+
// RegExp.escape has been added to the newer ES2025 target, but I'm not
|
|
57
|
+
// ready to change that just yet
|
|
58
|
+
// https://github.com/microsoft/TypeScript/pull/63046
|
|
59
|
+
`export \\* from ['"]${RegExp.escape(prismaClientLocation)}['"]`
|
|
60
|
+
).test(content);
|
|
47
61
|
};
|
|
48
62
|
export {
|
|
49
63
|
dbReexportsPrismaClient,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/internal",
|
|
3
|
-
"version": "3.0.0-canary.
|
|
3
|
+
"version": "3.0.0-canary.13597+48d06b4d0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/cedarjs/cedar.git",
|
|
@@ -150,11 +150,11 @@
|
|
|
150
150
|
"@babel/plugin-transform-typescript": "^7.26.8",
|
|
151
151
|
"@babel/runtime-corejs3": "7.29.0",
|
|
152
152
|
"@babel/traverse": "7.29.0",
|
|
153
|
-
"@cedarjs/babel-config": "3.0.0-canary.
|
|
154
|
-
"@cedarjs/graphql-server": "3.0.0-canary.
|
|
155
|
-
"@cedarjs/project-config": "3.0.0-canary.
|
|
156
|
-
"@cedarjs/router": "3.0.0-canary.
|
|
157
|
-
"@cedarjs/structure": "3.0.0-canary.
|
|
153
|
+
"@cedarjs/babel-config": "3.0.0-canary.13597",
|
|
154
|
+
"@cedarjs/graphql-server": "3.0.0-canary.13597",
|
|
155
|
+
"@cedarjs/project-config": "3.0.0-canary.13597",
|
|
156
|
+
"@cedarjs/router": "3.0.0-canary.13597",
|
|
157
|
+
"@cedarjs/structure": "3.0.0-canary.13597",
|
|
158
158
|
"@graphql-codegen/add": "6.0.0",
|
|
159
159
|
"@graphql-codegen/cli": "6.2.1",
|
|
160
160
|
"@graphql-codegen/client-preset": "5.2.4",
|
|
@@ -186,7 +186,7 @@
|
|
|
186
186
|
},
|
|
187
187
|
"devDependencies": {
|
|
188
188
|
"@arethetypeswrong/cli": "0.18.2",
|
|
189
|
-
"@cedarjs/framework-tools": "3.0.0-canary.
|
|
189
|
+
"@cedarjs/framework-tools": "3.0.0-canary.13597",
|
|
190
190
|
"concurrently": "9.2.1",
|
|
191
191
|
"graphql-tag": "2.12.6",
|
|
192
192
|
"publint": "0.3.18",
|
|
@@ -196,5 +196,5 @@
|
|
|
196
196
|
"publishConfig": {
|
|
197
197
|
"access": "public"
|
|
198
198
|
},
|
|
199
|
-
"gitHead": "
|
|
199
|
+
"gitHead": "48d06b4d0cd4972ec0b019b7fd236ef0e0af1220"
|
|
200
200
|
}
|