@m1212e/rumble 0.12.20 → 0.12.21
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/out/index.cjs +8 -8
- package/out/index.cjs.map +1 -1
- package/out/index.d.cts.map +1 -1
- package/out/index.d.mts.map +1 -1
- package/out/index.mjs +8 -8
- package/out/index.mjs.map +1 -1
- package/package.json +1 -1
package/out/index.cjs
CHANGED
|
@@ -48,19 +48,16 @@ __pothos_plugin_smart_subscriptions = __toESM(__pothos_plugin_smart_subscription
|
|
|
48
48
|
let graphql_scalars = require("graphql-scalars");
|
|
49
49
|
|
|
50
50
|
//#region lib/client/generate/client.ts
|
|
51
|
-
function generateClient({ apiUrl, rumbleImportPath, useExternalUrqlClient, availableSubscriptions,
|
|
51
|
+
function generateClient({ apiUrl, rumbleImportPath, useExternalUrqlClient, availableSubscriptions, schemaPath }) {
|
|
52
52
|
const imports = [];
|
|
53
53
|
let code = "";
|
|
54
54
|
if (typeof useExternalUrqlClient === "string") imports.push(`import { urqlClient } from "${useExternalUrqlClient}";`);
|
|
55
55
|
imports.push(`import { Client, fetchExchange } from '@urql/core';`);
|
|
56
56
|
imports.push(`import { cacheExchange } from '@urql/exchange-graphcache';`);
|
|
57
57
|
imports.push(`import { nativeDateExchange } from '${rumbleImportPath}';`);
|
|
58
|
+
imports.push(`import { schema } from '${schemaPath}';`);
|
|
58
59
|
imports.push(`import { makeLiveQuery, makeMutation, makeSubscription, makeQuery } from '${rumbleImportPath}';`);
|
|
59
60
|
code += `
|
|
60
|
-
|
|
61
|
-
// @ts-ignore
|
|
62
|
-
export const schema = ${schema ? (0, devalue.uneval)((0, __urql_introspection.minifyIntrospectionQuery)((0, __urql_introspection.getIntrospectedSchema)(schema))) : "undefined"};
|
|
63
|
-
|
|
64
61
|
export const defaultOptions: ConstructorParameters<Client>[0] = {
|
|
65
62
|
url: "${apiUrl ?? "PLEASE PROVIDE A URL WHEN GENERATING OR IMPORT AN EXTERNAL URQL CLIENT"}",
|
|
66
63
|
fetchSubscriptions: true,
|
|
@@ -69,7 +66,7 @@ export const defaultOptions: ConstructorParameters<Client>[0] = {
|
|
|
69
66
|
credentials: "include",
|
|
70
67
|
},
|
|
71
68
|
requestPolicy: "cache-and-network",
|
|
72
|
-
}
|
|
69
|
+
}
|
|
73
70
|
`;
|
|
74
71
|
if (!useExternalUrqlClient) code += `
|
|
75
72
|
const urqlClient = new Client(defaultOptions);
|
|
@@ -233,16 +230,18 @@ async function generateFromSchema({ outputPath, schema, rumbleImportPath = "@m12
|
|
|
233
230
|
export type ${key} = ${rep};
|
|
234
231
|
`;
|
|
235
232
|
}
|
|
233
|
+
const schemaFileName = "schema";
|
|
236
234
|
const c = generateClient({
|
|
237
235
|
apiUrl,
|
|
238
|
-
|
|
236
|
+
schemaPath: `./${schemaFileName}`,
|
|
239
237
|
useExternalUrqlClient,
|
|
240
238
|
rumbleImportPath,
|
|
241
239
|
availableSubscriptions: new Set(Object.keys(schema.getSubscriptionType()?.getFields() || {}))
|
|
242
240
|
});
|
|
243
241
|
imports.push(...c.imports);
|
|
244
242
|
code += c.code;
|
|
245
|
-
await (0, node_fs_promises.writeFile)((0, node_path.join)(outputPath, "client.ts"), `${imports.join("\n")}\n${code}`)
|
|
243
|
+
await Promise.all([(0, node_fs_promises.writeFile)((0, node_path.join)(outputPath, "client.ts"), `${imports.join("\n")}\n${code}`), (0, node_fs_promises.writeFile)((0, node_path.join)(outputPath, `${schemaFileName}.ts`), `// @ts-ignore
|
|
244
|
+
export const schema = ${(0, devalue.uneval)((0, __urql_introspection.minifyIntrospectionQuery)((0, __urql_introspection.getIntrospectedSchema)(schema)))}`)]);
|
|
246
245
|
}
|
|
247
246
|
|
|
248
247
|
//#endregion
|
|
@@ -316,6 +315,7 @@ function stringifyArgumentObjectToGraphqlList(args) {
|
|
|
316
315
|
return `(${entries.map(([key, value]) => `${key}: ${stringifyArgumentValue(value)}`).join(", ")})`;
|
|
317
316
|
}
|
|
318
317
|
function stringifyArgumentValue(arg) {
|
|
318
|
+
if (arg === null) return "null";
|
|
319
319
|
switch (typeof arg) {
|
|
320
320
|
case "string": return `"${arg}"`;
|
|
321
321
|
case "number": return `${arg}`;
|