@ramathibodi/nuxt-commons 0.1.10 → 0.1.12
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/module.json
CHANGED
|
@@ -21,11 +21,13 @@ export function useGraphQl() {
|
|
|
21
21
|
return new Promise((resolve, reject) => {
|
|
22
22
|
const { onResult, onError } = useQuery(gql(builder.query), builder.variables, { fetchPolicy: cache ? "cache-first" : "no-cache" });
|
|
23
23
|
onResult((queryResult) => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
if (!queryResult.loading) {
|
|
25
|
+
const dataObject = queryResult.data;
|
|
26
|
+
try {
|
|
27
|
+
resolve(dataObject[operation]);
|
|
28
|
+
} catch (error) {
|
|
29
|
+
reject(error);
|
|
30
|
+
}
|
|
29
31
|
}
|
|
30
32
|
});
|
|
31
33
|
onError((error) => {
|
package/package.json
CHANGED
package/scripts/postInstall.cjs
CHANGED
|
@@ -25,15 +25,6 @@ function copyDirectory(srcDir, destDir) {
|
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
// Function to add copied files to git
|
|
29
|
-
function addFilesToGit(files, projectRoot) {
|
|
30
|
-
files.forEach(file => {
|
|
31
|
-
const filePath = path.join(projectRoot, file);
|
|
32
|
-
execSync(`git add ${filePath}`, { stdio: 'inherit' });
|
|
33
|
-
console.log(`Added ${filePath} to git`);
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
|
|
37
28
|
// Function to modify package.json to add a new script
|
|
38
29
|
function addScriptToPackageJson(scriptName, scriptCommand) {
|
|
39
30
|
const packageJsonPath = path.join(process.env.INIT_CWD, 'package.json');
|
|
@@ -68,9 +59,9 @@ copyDirectory(srcDir, destDir);
|
|
|
68
59
|
// Add new script to package.json
|
|
69
60
|
addScriptToPackageJson('codegen', 'graphql-codegen --require dotenv/config --config ./.codegen/codegen.ts dotenv_config_path=.env');
|
|
70
61
|
|
|
71
|
-
// Add copied files to git
|
|
72
|
-
const copiedFiles = fs.readdirSync(srcDir).map(file => path.join('.', file));
|
|
73
|
-
addFilesToGit(copiedFiles, destDir);
|
|
74
|
-
|
|
75
62
|
// Run npm run codegen safely
|
|
76
|
-
|
|
63
|
+
if (!fs.existsSync(path.join(destDir, "types","graphql.ts")) || !fs.existsSync(path.join(destDir, "composables","graphqlObject.ts"))) {
|
|
64
|
+
if (process.env.NUXT_PUBLIC_WS_GRAPHQL) runCodegen(destDir);
|
|
65
|
+
} else {
|
|
66
|
+
console.log('Skipping codegen');
|
|
67
|
+
}
|
|
@@ -26,7 +26,7 @@ const config: CodegenConfig = {
|
|
|
26
26
|
},'./.codegen/plugin-schema-object.js'],
|
|
27
27
|
},
|
|
28
28
|
},
|
|
29
|
-
hooks: { afterAllFileWrite: ['prettier --parser typescript --tab-width 4 --write'
|
|
29
|
+
hooks: { afterAllFileWrite: ['prettier --parser typescript --tab-width 4 --write'] }
|
|
30
30
|
};
|
|
31
31
|
|
|
32
32
|
export default config;
|
|
@@ -96,6 +96,12 @@ module.exports = {
|
|
|
96
96
|
return `
|
|
97
97
|
import * as graphQlClass from "~/types/graphql"
|
|
98
98
|
import { useGraphQlOperation } from "#imports";
|
|
99
|
+
import type {
|
|
100
|
+
graphqlInputObject,
|
|
101
|
+
graphqlOperationObject,
|
|
102
|
+
graphqlTypeObject,
|
|
103
|
+
graphqlVariable
|
|
104
|
+
} from "#build/types/graphqlOperation";
|
|
99
105
|
|
|
100
106
|
export const scalarType = ${JSON.stringify(scalarType)}
|
|
101
107
|
|