@trackunit/iris-app-build-utilities 2.1.24 → 2.1.25
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
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/iris-app-build-utilities",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.25",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
5
|
"repository": "https://github.com/Trackunit/manager",
|
|
6
6
|
"engines": {
|
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
"@nx/react": "22.7.5",
|
|
14
14
|
"tslib": "^2.6.2",
|
|
15
15
|
"csp-header": "^6.3.1",
|
|
16
|
-
"@trackunit/iris-app-api": "2.1.
|
|
16
|
+
"@trackunit/iris-app-api": "2.1.24",
|
|
17
17
|
"@nx/devkit": "22.7.5",
|
|
18
|
-
"@trackunit/shared-utils": "1.15.
|
|
18
|
+
"@trackunit/shared-utils": "1.15.86",
|
|
19
19
|
"http-proxy-middleware": "3.0.5",
|
|
20
20
|
"marked": "14.1.2",
|
|
21
21
|
"pacote": "^21.0.4",
|
|
@@ -1,9 +1,23 @@
|
|
|
1
1
|
import { CodegenConfig } from "@graphql-codegen/cli";
|
|
2
|
+
/**
|
|
3
|
+
* Which schema the generated operations are type-checked against.
|
|
4
|
+
*
|
|
5
|
+
* - `auto`: the internal schema when the monorepo checkout provides it, otherwise the public
|
|
6
|
+
* endpoint. Internal is a superset of public, so this is the right default inside manager.
|
|
7
|
+
* - `public`: the public schema only. Required for libraries published to npm, where generating
|
|
8
|
+
* against the internal superset would let internal-only fields compile into a public package.
|
|
9
|
+
*/
|
|
10
|
+
export type GraphqlCodegenSchemaSource = "auto" | "public";
|
|
11
|
+
export type GraphqlCodegenOptions = {
|
|
12
|
+
readonly schemaSource?: GraphqlCodegenSchemaSource;
|
|
13
|
+
};
|
|
2
14
|
/**
|
|
3
15
|
* This function returns the codegen config for trackunit public graphql-codegen.
|
|
4
16
|
*
|
|
5
17
|
* @param nxLibPath The library path.
|
|
6
18
|
* @param gqlFilePaths (optional) An array of library relative paths to the graphql-files to generate hooks for.
|
|
19
|
+
* @param options (optional) Code generation options.
|
|
20
|
+
* @param options.schemaSource (optional) Which schema to generate against. Defaults to `auto`.
|
|
7
21
|
* @returns {CodegenConfig } GraphQL code generation config.
|
|
8
22
|
*/
|
|
9
|
-
export declare const getGraphqlCodegenConfig: (nxLibPath: string, gqlFilePaths?: Array<string
|
|
23
|
+
export declare const getGraphqlCodegenConfig: (nxLibPath: string, gqlFilePaths?: Array<string>, options?: GraphqlCodegenOptions) => CodegenConfig;
|
|
@@ -4,18 +4,27 @@ exports.getGraphqlCodegenConfig = void 0;
|
|
|
4
4
|
const fs_1 = require("fs");
|
|
5
5
|
const path_1 = require("path");
|
|
6
6
|
const toPosixWorkspaceRelative_1 = require("./toPosixWorkspaceRelative");
|
|
7
|
+
const PUBLIC_SCHEMA_URL = "https://iris.trackunit.com/api/graphql/";
|
|
8
|
+
const workspaceSchemaPath = (schemaLib, schemaFile) => (0, path_1.join)(__dirname, "..", "..", "..", "..", "libs", "api", schemaLib, "generated", schemaFile);
|
|
9
|
+
const resolveSchema = (schemaSource) => {
|
|
10
|
+
if (schemaSource === "public") {
|
|
11
|
+
const publicSchemaFilePath = workspaceSchemaPath("public-gql-schema", "public-schema.gql");
|
|
12
|
+
return (0, fs_1.existsSync)(publicSchemaFilePath) ? (0, toPosixWorkspaceRelative_1.toPosixWorkspaceRelative)(publicSchemaFilePath) : PUBLIC_SCHEMA_URL;
|
|
13
|
+
}
|
|
14
|
+
const internalSchemaFilePath = workspaceSchemaPath("internal-gql-schema", "internal-schema.gql");
|
|
15
|
+
return (0, fs_1.existsSync)(internalSchemaFilePath) ? (0, toPosixWorkspaceRelative_1.toPosixWorkspaceRelative)(internalSchemaFilePath) : PUBLIC_SCHEMA_URL;
|
|
16
|
+
};
|
|
7
17
|
/**
|
|
8
18
|
* This function returns the codegen config for trackunit public graphql-codegen.
|
|
9
19
|
*
|
|
10
20
|
* @param nxLibPath The library path.
|
|
11
21
|
* @param gqlFilePaths (optional) An array of library relative paths to the graphql-files to generate hooks for.
|
|
22
|
+
* @param options (optional) Code generation options.
|
|
23
|
+
* @param options.schemaSource (optional) Which schema to generate against. Defaults to `auto`.
|
|
12
24
|
* @returns {CodegenConfig } GraphQL code generation config.
|
|
13
25
|
*/
|
|
14
|
-
const getGraphqlCodegenConfig = (nxLibPath, gqlFilePaths) => {
|
|
15
|
-
const
|
|
16
|
-
const publicSchemaUrlOrInternalSchemaPath = (0, fs_1.existsSync)(internalSchemaFilePath)
|
|
17
|
-
? (0, toPosixWorkspaceRelative_1.toPosixWorkspaceRelative)(internalSchemaFilePath)
|
|
18
|
-
: "https://iris.trackunit.com/api/graphql/";
|
|
26
|
+
const getGraphqlCodegenConfig = (nxLibPath, gqlFilePaths, options) => {
|
|
27
|
+
const publicSchemaUrlOrInternalSchemaPath = resolveSchema(options?.schemaSource ?? "auto");
|
|
19
28
|
// eslint-disable-next-line no-console
|
|
20
29
|
console.log(`Using schema: ${publicSchemaUrlOrInternalSchemaPath}`);
|
|
21
30
|
// Pointers handed to graphql-codegen must be workspace-relative posix paths: absolute Windows
|