@trackunit/react-graphql-tools 0.0.1-alpha-307439490d.0

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 ADDED
@@ -0,0 +1,5 @@
1
+ # Changelog
2
+
3
+ This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
+
5
+ ## 0.0.1-alpha-307439490d.0 (2023-03-09)
package/README.md ADDED
@@ -0,0 +1,38 @@
1
+ > **⚠️ Beta**
2
+ >
3
+ > This is a beta version and subject to change without notice.
4
+
5
+ # Trackunit React GraphQL tools
6
+
7
+ ## Basic Usage
8
+ This tool allows you to generate React Hooks for your GraphQL files.
9
+ Just add this executor to the project with *.graphql files, then it creates React hooks.
10
+
11
+ In the project.json targets add:
12
+ ```
13
+ "graphql-hooks": {
14
+ "executor": "@trackunit/react-graphql-tools:createHooks"
15
+ },
16
+ ```
17
+ then run it with:
18
+
19
+ ```
20
+ nx run <your project>:graphql-hooks
21
+ ```
22
+
23
+ It will create ts file in the src folder for the project
24
+ ```
25
+ <your project>/src/generated/graphql-api.tsx
26
+ ```
27
+ * It is recommended you add **/generated/graphql-api.tsx to your .gitignore file
28
+ *
29
+ ## Trackunit Iris Apps
30
+
31
+ Trackunit Iris Apps are used by external developers to integrate custom functionality into [the Trackunit Manager platform](https://www.trackunit.com/services/manager/).
32
+
33
+ For more info and a full guide on Iris App SDK Development, please visit our [Developer Hub](https://developers.trackunit.com/).
34
+ ## Trackunit
35
+ This package was developed by Trackunit ApS.
36
+ Trackunit is the leading SaaS-based IoT solution for the construction industry, offering an ecosystem of hardware, fleet management software & telematics.
37
+
38
+ ![The Trackunit logo](https://trackunit.com/wp-content/uploads/2022/03/top-logo.svg)
package/executors.json ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "executors": {
4
+ "createHooks": {
5
+ "implementation": "./src/executors/createHooks/executor",
6
+ "schema": "./src/executors/createHooks/schema.json",
7
+ "description": "Runs through `createHooks`."
8
+ }
9
+ }
10
+ }
package/package.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "name": "@trackunit/react-graphql-tools",
3
+ "version": "0.0.1-alpha-307439490d.0",
4
+ "main": "src/index.js",
5
+ "executors": "./executors.json",
6
+ "repository": "https://github.com/Trackunit/manager",
7
+ "license": "SEE LICENSE IN LICENSE.txt",
8
+ "types": "./src/index.d.ts",
9
+ "dependencies": {
10
+ "@trackunit/nx-utils": "0.0.1-alpha-307439490d.0",
11
+ "tslib": "2.4.1"
12
+ },
13
+ "peerDependencies": {}
14
+ }
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CreateGraphqlHooks = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const generateHooks_1 = require("./generateHooks");
6
+ /**
7
+ * This executor generates react hooks for all graphql files.
8
+ *
9
+ * @param _unused unused props from nx
10
+ * @param context The execution context for this executor
11
+ * @returns success when finished
12
+ */
13
+ const CreateGraphqlHooks = (_unused, context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
14
+ const nxRoot = `${context.root}`;
15
+ const libRoot = context.workspace.projects[context.projectName].root;
16
+ const fullLibRoot = `${nxRoot}/${libRoot}`;
17
+ yield (0, generateHooks_1.generateHooks)("https://dev.manager.trackunit.com/public/api/gql/", fullLibRoot + "/src");
18
+ return { success: 1 };
19
+ });
20
+ exports.CreateGraphqlHooks = CreateGraphqlHooks;
21
+ exports.default = exports.CreateGraphqlHooks;
22
+ //# sourceMappingURL=executor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../../../../libs/react/graphql-tools/src/executors/createHooks/executor.ts"],"names":[],"mappings":";;;;AACA,mDAAgD;AAEhD;;;;;;GAMG;AACI,MAAM,kBAAkB,GAAG,CAAO,OAAgB,EAAE,OAAwB,EAAE,EAAE;IACrF,MAAM,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAEjC,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,WAAY,CAAC,CAAC,IAAI,CAAC;IACtE,MAAM,WAAW,GAAG,GAAG,MAAM,IAAI,OAAO,EAAE,CAAC;IAE3C,MAAM,IAAA,6BAAa,EAAC,mDAAmD,EAAE,WAAW,GAAG,MAAM,CAAC,CAAC;IAC/F,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;AACxB,CAAC,CAAA,CAAC;AARW,QAAA,kBAAkB,sBAQ7B;AAEF,kBAAe,0BAAkB,CAAC","sourcesContent":["import { ExecutorContext } from \"@nrwl/devkit\";\nimport { generateHooks } from \"./generateHooks\";\n\n/**\n * This executor generates react hooks for all graphql files.\n *\n * @param _unused unused props from nx\n * @param context The execution context for this executor\n * @returns success when finished\n */\nexport const CreateGraphqlHooks = async (_unused: unknown, context: ExecutorContext) => {\n const nxRoot = `${context.root}`;\n\n const libRoot = context.workspace.projects[context.projectName!].root;\n const fullLibRoot = `${nxRoot}/${libRoot}`;\n\n await generateHooks(\"https://dev.manager.trackunit.com/public/api/gql/\", fullLibRoot + \"/src\");\n return { success: 1 };\n};\n\nexport default CreateGraphqlHooks;\n"]}
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateHooks = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const cli_1 = require("@graphql-codegen/cli");
6
+ /**
7
+ * Generates React hooks from your graphql files.
8
+ *
9
+ * @param schemaUrl schema url to use.
10
+ * @param srcPath the srcPath to look for options glob.
11
+ * @param options.name the name of the output file.
12
+ * @param options.graphqlGlob the options glob allows you to override the default.
13
+ * @param options.plugins the options list of plugins to use.
14
+ */
15
+ const generateHooks = (schemaUrl, srcPath, options = {
16
+ name: "generated/graphql-api.tsx",
17
+ graphqlGlob: "*.graphql",
18
+ plugins: ["typescript", "typescript-operations", "typescript-react-apollo", "fragment-matcher"],
19
+ }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
20
+ const codegenOptions = {
21
+ generates: {},
22
+ };
23
+ codegenOptions.generates[`${srcPath}/${options.name}`] = Object.assign({ schema: schemaUrl, documents: `${srcPath}/**/${options.graphqlGlob}`, config: {
24
+ withHooks: true,
25
+ withHOC: false,
26
+ withComponent: false,
27
+ noNamespaces: true,
28
+ declarationKind: "interface",
29
+ namingConvention: {
30
+ typeNames: "keep",
31
+ enumValues: "pascal-case#pascalCase",
32
+ },
33
+ scalars: {
34
+ Date: "Date",
35
+ DateTime: "Date",
36
+ },
37
+ }, plugins: options.plugins }, options.overridePluginConfig);
38
+ yield (0, cli_1.generate)(codegenOptions, true).catch(e => {
39
+ // eslint-disable-next-line no-console
40
+ console.error("❌ There was an error generating GraphQL types", e);
41
+ process.exit(1);
42
+ });
43
+ });
44
+ exports.generateHooks = generateHooks;
45
+ //# sourceMappingURL=generateHooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateHooks.js","sourceRoot":"","sources":["../../../../../../../libs/react/graphql-tools/src/executors/createHooks/generateHooks.ts"],"names":[],"mappings":";;;;AAAA,8CAA+D;AAE/D;;;;;;;;GAQG;AACI,MAAM,aAAa,GAAG,CAC3B,SAAiB,EACjB,OAAe,EACf,UAKI;IACF,IAAI,EAAE,2BAA2B;IACjC,WAAW,EAAE,WAAW;IACxB,OAAO,EAAE,CAAC,YAAY,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,kBAAkB,CAAC;CAChG,EACD,EAAE;IACF,MAAM,cAAc,GAAkB;QACpC,SAAS,EAAE,EAAE;KACd,CAAC;IAEF,cAAc,CAAC,SAAS,CAAC,GAAG,OAAO,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC,mBACpD,MAAM,EAAE,SAAS,EACjB,SAAS,EAAE,GAAG,OAAO,OAAO,OAAO,CAAC,WAAW,EAAE,EACjD,MAAM,EAAE;YACN,SAAS,EAAE,IAAI;YACf,OAAO,EAAE,KAAK;YACd,aAAa,EAAE,KAAK;YACpB,YAAY,EAAE,IAAI;YAClB,eAAe,EAAE,WAAW;YAC5B,gBAAgB,EAAE;gBAChB,SAAS,EAAE,MAAM;gBACjB,UAAU,EAAE,wBAAwB;aACrC;YACD,OAAO,EAAE;gBACP,IAAI,EAAE,MAAM;gBACZ,QAAQ,EAAE,MAAM;aACjB;SACF,EACD,OAAO,EAAE,OAAO,CAAC,OAAO,IACrB,OAAO,CAAC,oBAAoB,CAChC,CAAC;IAEF,MAAM,IAAA,cAAQ,EAAC,cAAc,EAAE,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;QAC7C,sCAAsC;QACtC,OAAO,CAAC,KAAK,CAAC,+CAA+C,EAAE,CAAC,CAAC,CAAC;QAClE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC,CAAA,CAAC;AA7CW,QAAA,aAAa,iBA6CxB","sourcesContent":["import { CodegenConfig, generate } from \"@graphql-codegen/cli\";\n\n/**\n * Generates React hooks from your graphql files.\n *\n * @param schemaUrl schema url to use.\n * @param srcPath the srcPath to look for options glob.\n * @param options.name the name of the output file.\n * @param options.graphqlGlob the options glob allows you to override the default.\n * @param options.plugins the options list of plugins to use.\n */\nexport const generateHooks = async (\n schemaUrl: string,\n srcPath: string,\n options: {\n name: string;\n graphqlGlob: string;\n plugins: string[];\n overridePluginConfig?: CodegenConfig;\n } = {\n name: \"generated/graphql-api.tsx\",\n graphqlGlob: \"*.graphql\",\n plugins: [\"typescript\", \"typescript-operations\", \"typescript-react-apollo\", \"fragment-matcher\"],\n }\n) => {\n const codegenOptions: CodegenConfig = {\n generates: {},\n };\n\n codegenOptions.generates[`${srcPath}/${options.name}`] = {\n schema: schemaUrl,\n documents: `${srcPath}/**/${options.graphqlGlob}`,\n config: {\n withHooks: true,\n withHOC: false,\n withComponent: false,\n noNamespaces: true,\n declarationKind: \"interface\",\n namingConvention: {\n typeNames: \"keep\",\n enumValues: \"pascal-case#pascalCase\",\n },\n scalars: {\n Date: \"Date\",\n DateTime: \"Date\",\n },\n },\n plugins: options.plugins,\n ...options.overridePluginConfig,\n };\n\n await generate(codegenOptions, true).catch(e => {\n // eslint-disable-next-line no-console\n console.error(\"❌ There was an error generating GraphQL types\", e);\n process.exit(1);\n });\n};\n"]}
@@ -0,0 +1 @@
1
+ export interface CreateGraphqlHooksExecutorSchema {}
@@ -0,0 +1,6 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "type": "object",
4
+ "cli": "nx",
5
+ "properties": {}
6
+ }
package/src/index.js ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CreateGraphqlHooks = void 0;
4
+ var executor_1 = require("./executors/createHooks/executor");
5
+ Object.defineProperty(exports, "CreateGraphqlHooks", { enumerable: true, get: function () { return executor_1.CreateGraphqlHooks; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/react/graphql-tools/src/index.ts"],"names":[],"mappings":";;;AAAA,6DAAsE;AAA7D,8GAAA,kBAAkB,OAAA","sourcesContent":["export { CreateGraphqlHooks } from \"./executors/createHooks/executor\";\nexport { CreateGraphqlHooksExecutorSchema } from \"./executors/createHooks/schema\";\n"]}