@trackunit/iris-app-build-utilities 2.4.15 → 2.4.16

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
@@ -1,3 +1,14 @@
1
+ ## 2.4.16 (2026-08-24)
2
+
3
+ ### 🚀 Features
4
+
5
+ - **react-graphql-tools:** document required authorization scopes in generated mocks ([8b500687a87](https://github.com/Trackunit/manager/commit/8b500687a87))
6
+
7
+ ### ❤️ Thank You
8
+
9
+ - Cursor @cursoragent
10
+ - Mikkel Thorbjørn Andersen
11
+
1
12
  ## 2.4.15 (2026-08-21)
2
13
 
3
14
  ### 🧱 Updated Dependencies
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/iris-app-build-utilities",
3
- "version": "2.4.15",
3
+ "version": "2.4.16",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "repository": "https://github.com/Trackunit/manager",
6
6
  "engines": {
@@ -11,6 +11,15 @@ export type GraphqlCodegenSchemaSource = "auto" | "public";
11
11
  export type GraphqlCodegenOptions = {
12
12
  readonly schemaSource?: GraphqlCodegenSchemaSource;
13
13
  };
14
+ /**
15
+ * Resolves the schema pointer codegen generates against for the given source: a workspace-relative
16
+ * posix path to the checked-out schema when available, otherwise the remote public endpoint URL.
17
+ * Exported so tooling that runs alongside codegen (e.g. mock scrubbing) can read the same schema.
18
+ *
19
+ * @param schemaSource Which schema to resolve. Defaults to `auto` (internal, falling back to public).
20
+ * @returns {string} A workspace-relative posix schema path or the public schema endpoint URL.
21
+ */
22
+ export declare const resolveSchema: (schemaSource?: GraphqlCodegenSchemaSource) => string;
14
23
  /**
15
24
  * This function returns the codegen config for trackunit public graphql-codegen.
16
25
  *
@@ -1,12 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getGraphqlCodegenConfig = void 0;
3
+ exports.getGraphqlCodegenConfig = exports.resolveSchema = void 0;
4
4
  const fs_1 = require("fs");
5
5
  const path_1 = require("path");
6
6
  const toPosixWorkspaceRelative_1 = require("./toPosixWorkspaceRelative");
7
7
  const PUBLIC_SCHEMA_URL = "https://iris.trackunit.com/api/graphql/";
8
8
  const workspaceSchemaPath = (schemaLib, schemaFile) => (0, path_1.join)(__dirname, "..", "..", "..", "..", "libs", "api", schemaLib, "generated", schemaFile);
9
- const resolveSchema = (schemaSource) => {
9
+ /**
10
+ * Resolves the schema pointer codegen generates against for the given source: a workspace-relative
11
+ * posix path to the checked-out schema when available, otherwise the remote public endpoint URL.
12
+ * Exported so tooling that runs alongside codegen (e.g. mock scrubbing) can read the same schema.
13
+ *
14
+ * @param schemaSource Which schema to resolve. Defaults to `auto` (internal, falling back to public).
15
+ * @returns {string} A workspace-relative posix schema path or the public schema endpoint URL.
16
+ */
17
+ const resolveSchema = (schemaSource = "auto") => {
10
18
  if (schemaSource === "public") {
11
19
  const publicSchemaFilePath = workspaceSchemaPath("public-gql-schema", "public-schema.gql");
12
20
  return (0, fs_1.existsSync)(publicSchemaFilePath) ? (0, toPosixWorkspaceRelative_1.toPosixWorkspaceRelative)(publicSchemaFilePath) : PUBLIC_SCHEMA_URL;
@@ -14,6 +22,7 @@ const resolveSchema = (schemaSource) => {
14
22
  const internalSchemaFilePath = workspaceSchemaPath("internal-gql-schema", "internal-schema.gql");
15
23
  return (0, fs_1.existsSync)(internalSchemaFilePath) ? (0, toPosixWorkspaceRelative_1.toPosixWorkspaceRelative)(internalSchemaFilePath) : PUBLIC_SCHEMA_URL;
16
24
  };
25
+ exports.resolveSchema = resolveSchema;
17
26
  /**
18
27
  * This function returns the codegen config for trackunit public graphql-codegen.
19
28
  *
@@ -24,7 +33,7 @@ const resolveSchema = (schemaSource) => {
24
33
  * @returns {CodegenConfig } GraphQL code generation config.
25
34
  */
26
35
  const getGraphqlCodegenConfig = (nxLibPath, gqlFilePaths, options) => {
27
- const publicSchemaUrlOrInternalSchemaPath = resolveSchema(options?.schemaSource ?? "auto");
36
+ const publicSchemaUrlOrInternalSchemaPath = (0, exports.resolveSchema)(options?.schemaSource ?? "auto");
28
37
  // eslint-disable-next-line no-console
29
38
  console.log(`Using schema: ${publicSchemaUrlOrInternalSchemaPath}`);
30
39
  // Pointers handed to graphql-codegen must be workspace-relative posix paths: absolute Windows
@@ -1 +1 @@
1
- {"version":3,"file":"getGraphqlCodeGenConfig.js","sourceRoot":"","sources":["../../../../../libs/iris-app-sdk/iris-app-build-utilities/src/getGraphqlCodeGenConfig.ts"],"names":[],"mappings":";;;AACA,2BAAwC;AACxC,+BAA4B;AAC5B,yEAAsE;AAEtE,MAAM,iBAAiB,GAAG,yCAAyC,CAAC;AAEpE,MAAM,mBAAmB,GAAG,CAAC,SAAiB,EAAE,UAAkB,EAAU,EAAE,CAC5E,IAAA,WAAI,EAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;AAgB7F,MAAM,aAAa,GAAG,CAAC,YAAwC,EAAU,EAAE;IACzE,IAAI,YAAY,KAAK,QAAQ,EAAE,CAAC;QAC9B,MAAM,oBAAoB,GAAG,mBAAmB,CAAC,mBAAmB,EAAE,mBAAmB,CAAC,CAAC;QAE3F,OAAO,IAAA,eAAU,EAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,IAAA,mDAAwB,EAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC;IAC/G,CAAC;IAED,MAAM,sBAAsB,GAAG,mBAAmB,CAAC,qBAAqB,EAAE,qBAAqB,CAAC,CAAC;IAEjG,OAAO,IAAA,eAAU,EAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,IAAA,mDAAwB,EAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC;AACnH,CAAC,CAAC;AAEF;;;;;;;;GAQG;AACI,MAAM,uBAAuB,GAIf,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qBACxE;iBACF;aACF;SACF;QACD,MAAM,EAAE;YACN,OAAO,EAAE;gBACP,MAAM,EAAE,QAAQ;gBAChB,IAAI,EAAE,mBAAmB;gBACzB,QAAQ,EAAE,mBAAmB;gBAC7B,kBAAkB,EAAE,8DAA8D;gBAClF,qBAAqB,EAAE,uBAAuB;gBAC9C,WAAW,EAAE,QAAQ;gBACrB,YAAY,EAAE,QAAQ;gBACtB,QAAQ,EAAE,QAAQ;gBAClB,GAAG,EAAE,QAAQ;aACd;YACD,gBAAgB,EAAE;gBAChB,SAAS,EAAE,MAAM;gBACjB,UAAU,EAAE,MAAM;aACnB;YACD,cAAc,EAAE;gBACd,KAAK,EAAE,IAAI;gBACX,UAAU,EAAE,KAAK;gBACjB,MAAM,EAAE,IAAI;gBACZ,YAAY,EAAE,IAAI;aACnB;SACF;QACD,YAAY,EAAE;YACZ,eAAe,EAAE,EAAE,kBAAkB,EAAE,iBAAiB,EAAE;YAC1D,QAAQ,EAAE,IAAI;YACd,cAAc,EAAE;gBACd,KAAK,EAAE,IAAI;gBACX,UAAU,EAAE,KAAK;gBACjB,MAAM,EAAE,IAAI;gBACZ,YAAY,EAAE,IAAI;aACnB;YACD,YAAY,EAAE,IAAI;YAClB,gBAAgB,EAAE;gBAChB,SAAS,EAAE,MAAM;gBACjB,UAAU,EAAE,MAAM;aACnB;SACF;KACF,CAAC;IAEF,OAAO;QACL,MAAM,EAAE,EAAE;QACV,iBAAiB,EAAE,IAAI,EAAE,yCAAyC;QAClE,SAAS;KACV,CAAC;AACJ,CAAC,CAAC;AAzFW,QAAA,uBAAuB,2BAyFlC","sourcesContent":["import { CodegenConfig } from \"@graphql-codegen/cli\";\nimport { existsSync, rmSync } from \"fs\";\nimport { join } from \"path\";\nimport { toPosixWorkspaceRelative } from \"./toPosixWorkspaceRelative\";\n\nconst PUBLIC_SCHEMA_URL = \"https://iris.trackunit.com/api/graphql/\";\n\nconst workspaceSchemaPath = (schemaLib: string, schemaFile: string): string =>\n join(__dirname, \"..\", \"..\", \"..\", \"..\", \"libs\", \"api\", schemaLib, \"generated\", schemaFile);\n\n/**\n * Which schema the generated operations are type-checked against.\n *\n * - `auto`: the internal schema when the monorepo checkout provides it, otherwise the public\n * endpoint. Internal is a superset of public, so this is the right default inside manager.\n * - `public`: the public schema only. Required for libraries published to npm, where generating\n * against the internal superset would let internal-only fields compile into a public package.\n */\nexport type GraphqlCodegenSchemaSource = \"auto\" | \"public\";\n\nexport type GraphqlCodegenOptions = {\n readonly schemaSource?: GraphqlCodegenSchemaSource;\n};\n\nconst resolveSchema = (schemaSource: GraphqlCodegenSchemaSource): string => {\n if (schemaSource === \"public\") {\n const publicSchemaFilePath = workspaceSchemaPath(\"public-gql-schema\", \"public-schema.gql\");\n\n return existsSync(publicSchemaFilePath) ? toPosixWorkspaceRelative(publicSchemaFilePath) : PUBLIC_SCHEMA_URL;\n }\n\n const internalSchemaFilePath = workspaceSchemaPath(\"internal-gql-schema\", \"internal-schema.gql\");\n\n return existsSync(internalSchemaFilePath) ? toPosixWorkspaceRelative(internalSchemaFilePath) : PUBLIC_SCHEMA_URL;\n};\n\n/**\n * This function returns the codegen config for trackunit public graphql-codegen.\n *\n * @param nxLibPath The library path.\n * @param gqlFilePaths (optional) An array of library relative paths to the graphql-files to generate hooks for.\n * @param options (optional) Code generation options.\n * @param options.schemaSource (optional) Which schema to generate against. Defaults to `auto`.\n * @returns {CodegenConfig } GraphQL code generation config.\n */\nexport const getGraphqlCodegenConfig: (\n nxLibPath: string,\n gqlFilePaths?: Array<string>,\n options?: GraphqlCodegenOptions\n) => CodegenConfig = (nxLibPath: string, gqlFilePaths?: Array<string>, options?: GraphqlCodegenOptions) => {\n const publicSchemaUrlOrInternalSchemaPath = resolveSchema(options?.schemaSource ?? \"auto\");\n\n // eslint-disable-next-line no-console\n console.log(`Using schema: ${publicSchemaUrlOrInternalSchemaPath}`);\n\n // Pointers handed to graphql-codegen must be workspace-relative posix paths: absolute Windows\n // paths contain a drive-letter colon that @graphql-tools' GitLoader misparses as a git\n // ref:path pointer, and the client preset turns the generates key into a `!`-exclusion too.\n const libPath = toPosixWorkspaceRelative(nxLibPath);\n // Filesystem operations stay on the caller-provided native path; only codegen pointers are\n // workspace-relative, so cleanup keeps working when cwd is not the workspace root.\n const generatedGqlOutputDir = join(nxLibPath, \"src\", \"generated\", \"graphql-api\");\n if (existsSync(generatedGqlOutputDir)) {\n rmSync(generatedGqlOutputDir, { recursive: true });\n // eslint-disable-next-line no-console\n console.log(`Cleanup path: ${generatedGqlOutputDir}`);\n }\n // The trailing / makes the gql client-preset happy - also on Windows\n const generatedGqlOutputFolder = `${libPath}/src/generated/graphql-api/`;\n const documents = gqlFilePaths && gqlFilePaths.length > 0 ? gqlFilePaths : [`${libPath}/src/**/*.graphql`];\n if (!gqlFilePaths) {\n documents.push(`!${libPath}/src/**/*-manager.graphql`);\n }\n\n const generates: CodegenConfig[\"generates\"] = {};\n generates[generatedGqlOutputFolder] = {\n schema: publicSchemaUrlOrInternalSchemaPath,\n documents,\n preset: \"client\",\n plugins: [\n {\n add: {\n content: [\n \"export type DateTimeISOString = string;\",\n \"import type { PublicIrisAppManifest } from '@trackunit/iris-app-api';\",\n ],\n },\n },\n ],\n config: {\n scalars: {\n Cursor: \"string\",\n Date: \"DateTimeISOString\",\n DateTime: \"DateTimeISOString\",\n GeoJSONCoordinates: \"[number, number] | [number, number][] | [number, number][][]\",\n PublicIrisAppManifest: \"PublicIrisAppManifest\",\n PhoneNumber: \"string\",\n EmailAddress: \"string\",\n Currency: \"string\",\n Url: \"string\",\n },\n namingConvention: {\n typeNames: \"keep\",\n enumValues: \"keep\",\n },\n avoidOptionals: {\n field: true,\n inputValue: false,\n object: true,\n defaultValue: true,\n },\n },\n presetConfig: {\n fragmentMasking: { unmaskFunctionName: \"getFragmentData\" },\n noExport: true,\n avoidOptionals: {\n field: true,\n inputValue: false,\n object: true,\n defaultValue: true,\n },\n noNamespaces: true,\n namingConvention: {\n typeNames: \"keep\",\n enumValues: \"keep\",\n },\n },\n };\n\n return {\n schema: \"\",\n ignoreNoDocuments: true, // for better experience with the watcher\n generates,\n };\n};\n"]}
1
+ {"version":3,"file":"getGraphqlCodeGenConfig.js","sourceRoot":"","sources":["../../../../../libs/iris-app-sdk/iris-app-build-utilities/src/getGraphqlCodeGenConfig.ts"],"names":[],"mappings":";;;AACA,2BAAwC;AACxC,+BAA4B;AAC5B,yEAAsE;AAEtE,MAAM,iBAAiB,GAAG,yCAAyC,CAAC;AAEpE,MAAM,mBAAmB,GAAG,CAAC,SAAiB,EAAE,UAAkB,EAAU,EAAE,CAC5E,IAAA,WAAI,EAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;AAgB7F;;;;;;;GAOG;AACI,MAAM,aAAa,GAAG,CAAC,eAA2C,MAAM,EAAU,EAAE;IACzF,IAAI,YAAY,KAAK,QAAQ,EAAE,CAAC;QAC9B,MAAM,oBAAoB,GAAG,mBAAmB,CAAC,mBAAmB,EAAE,mBAAmB,CAAC,CAAC;QAE3F,OAAO,IAAA,eAAU,EAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,IAAA,mDAAwB,EAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC;IAC/G,CAAC;IAED,MAAM,sBAAsB,GAAG,mBAAmB,CAAC,qBAAqB,EAAE,qBAAqB,CAAC,CAAC;IAEjG,OAAO,IAAA,eAAU,EAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,IAAA,mDAAwB,EAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC;AACnH,CAAC,CAAC;AAVW,QAAA,aAAa,iBAUxB;AAEF;;;;;;;;GAQG;AACI,MAAM,uBAAuB,GAIf,CAAC,SAAiB,EAAE,YAA4B,EAAE,OAA+B,EAAE,EAAE;IACxG,MAAM,mCAAmC,GAAG,IA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,QAAQ;gBAChB,IAAI,EAAE,mBAAmB;gBACzB,QAAQ,EAAE,mBAAmB;gBAC7B,kBAAkB,EAAE,8DAA8D;gBAClF,qBAAqB,EAAE,uBAAuB;gBAC9C,WAAW,EAAE,QAAQ;gBACrB,YAAY,EAAE,QAAQ;gBACtB,QAAQ,EAAE,QAAQ;gBAClB,GAAG,EAAE,QAAQ;aACd;YACD,gBAAgB,EAAE;gBAChB,SAAS,EAAE,MAAM;gBACjB,UAAU,EAAE,MAAM;aACnB;YACD,cAAc,EAAE;gBACd,KAAK,EAAE,IAAI;gBACX,UAAU,EAAE,KAAK;gBACjB,MAAM,EAAE,IAAI;gBACZ,YAAY,EAAE,IAAI;aACnB;SACF;QACD,YAAY,EAAE;YACZ,eAAe,EAAE,EAAE,kBAAkB,EAAE,iBAAiB,EAAE;YAC1D,QAAQ,EAAE,IAAI;YACd,cAAc,EAAE;gBACd,KAAK,EAAE,IAAI;gBACX,UAAU,EAAE,KAAK;gBACjB,MAAM,EAAE,IAAI;gBACZ,YAAY,EAAE,IAAI;aACnB;YACD,YAAY,EAAE,IAAI;YAClB,gBAAgB,EAAE;gBAChB,SAAS,EAAE,MAAM;gBACjB,UAAU,EAAE,MAAM;aACnB;SACF;KACF,CAAC;IAEF,OAAO;QACL,MAAM,EAAE,EAAE;QACV,iBAAiB,EAAE,IAAI,EAAE,yCAAyC;QAClE,SAAS;KACV,CAAC;AACJ,CAAC,CAAC;AAzFW,QAAA,uBAAuB,2BAyFlC","sourcesContent":["import { CodegenConfig } from \"@graphql-codegen/cli\";\nimport { existsSync, rmSync } from \"fs\";\nimport { join } from \"path\";\nimport { toPosixWorkspaceRelative } from \"./toPosixWorkspaceRelative\";\n\nconst PUBLIC_SCHEMA_URL = \"https://iris.trackunit.com/api/graphql/\";\n\nconst workspaceSchemaPath = (schemaLib: string, schemaFile: string): string =>\n join(__dirname, \"..\", \"..\", \"..\", \"..\", \"libs\", \"api\", schemaLib, \"generated\", schemaFile);\n\n/**\n * Which schema the generated operations are type-checked against.\n *\n * - `auto`: the internal schema when the monorepo checkout provides it, otherwise the public\n * endpoint. Internal is a superset of public, so this is the right default inside manager.\n * - `public`: the public schema only. Required for libraries published to npm, where generating\n * against the internal superset would let internal-only fields compile into a public package.\n */\nexport type GraphqlCodegenSchemaSource = \"auto\" | \"public\";\n\nexport type GraphqlCodegenOptions = {\n readonly schemaSource?: GraphqlCodegenSchemaSource;\n};\n\n/**\n * Resolves the schema pointer codegen generates against for the given source: a workspace-relative\n * posix path to the checked-out schema when available, otherwise the remote public endpoint URL.\n * Exported so tooling that runs alongside codegen (e.g. mock scrubbing) can read the same schema.\n *\n * @param schemaSource Which schema to resolve. Defaults to `auto` (internal, falling back to public).\n * @returns {string} A workspace-relative posix schema path or the public schema endpoint URL.\n */\nexport const resolveSchema = (schemaSource: GraphqlCodegenSchemaSource = \"auto\"): string => {\n if (schemaSource === \"public\") {\n const publicSchemaFilePath = workspaceSchemaPath(\"public-gql-schema\", \"public-schema.gql\");\n\n return existsSync(publicSchemaFilePath) ? toPosixWorkspaceRelative(publicSchemaFilePath) : PUBLIC_SCHEMA_URL;\n }\n\n const internalSchemaFilePath = workspaceSchemaPath(\"internal-gql-schema\", \"internal-schema.gql\");\n\n return existsSync(internalSchemaFilePath) ? toPosixWorkspaceRelative(internalSchemaFilePath) : PUBLIC_SCHEMA_URL;\n};\n\n/**\n * This function returns the codegen config for trackunit public graphql-codegen.\n *\n * @param nxLibPath The library path.\n * @param gqlFilePaths (optional) An array of library relative paths to the graphql-files to generate hooks for.\n * @param options (optional) Code generation options.\n * @param options.schemaSource (optional) Which schema to generate against. Defaults to `auto`.\n * @returns {CodegenConfig } GraphQL code generation config.\n */\nexport const getGraphqlCodegenConfig: (\n nxLibPath: string,\n gqlFilePaths?: Array<string>,\n options?: GraphqlCodegenOptions\n) => CodegenConfig = (nxLibPath: string, gqlFilePaths?: Array<string>, options?: GraphqlCodegenOptions) => {\n const publicSchemaUrlOrInternalSchemaPath = resolveSchema(options?.schemaSource ?? \"auto\");\n\n // eslint-disable-next-line no-console\n console.log(`Using schema: ${publicSchemaUrlOrInternalSchemaPath}`);\n\n // Pointers handed to graphql-codegen must be workspace-relative posix paths: absolute Windows\n // paths contain a drive-letter colon that @graphql-tools' GitLoader misparses as a git\n // ref:path pointer, and the client preset turns the generates key into a `!`-exclusion too.\n const libPath = toPosixWorkspaceRelative(nxLibPath);\n // Filesystem operations stay on the caller-provided native path; only codegen pointers are\n // workspace-relative, so cleanup keeps working when cwd is not the workspace root.\n const generatedGqlOutputDir = join(nxLibPath, \"src\", \"generated\", \"graphql-api\");\n if (existsSync(generatedGqlOutputDir)) {\n rmSync(generatedGqlOutputDir, { recursive: true });\n // eslint-disable-next-line no-console\n console.log(`Cleanup path: ${generatedGqlOutputDir}`);\n }\n // The trailing / makes the gql client-preset happy - also on Windows\n const generatedGqlOutputFolder = `${libPath}/src/generated/graphql-api/`;\n const documents = gqlFilePaths && gqlFilePaths.length > 0 ? gqlFilePaths : [`${libPath}/src/**/*.graphql`];\n if (!gqlFilePaths) {\n documents.push(`!${libPath}/src/**/*-manager.graphql`);\n }\n\n const generates: CodegenConfig[\"generates\"] = {};\n generates[generatedGqlOutputFolder] = {\n schema: publicSchemaUrlOrInternalSchemaPath,\n documents,\n preset: \"client\",\n plugins: [\n {\n add: {\n content: [\n \"export type DateTimeISOString = string;\",\n \"import type { PublicIrisAppManifest } from '@trackunit/iris-app-api';\",\n ],\n },\n },\n ],\n config: {\n scalars: {\n Cursor: \"string\",\n Date: \"DateTimeISOString\",\n DateTime: \"DateTimeISOString\",\n GeoJSONCoordinates: \"[number, number] | [number, number][] | [number, number][][]\",\n PublicIrisAppManifest: \"PublicIrisAppManifest\",\n PhoneNumber: \"string\",\n EmailAddress: \"string\",\n Currency: \"string\",\n Url: \"string\",\n },\n namingConvention: {\n typeNames: \"keep\",\n enumValues: \"keep\",\n },\n avoidOptionals: {\n field: true,\n inputValue: false,\n object: true,\n defaultValue: true,\n },\n },\n presetConfig: {\n fragmentMasking: { unmaskFunctionName: \"getFragmentData\" },\n noExport: true,\n avoidOptionals: {\n field: true,\n inputValue: false,\n object: true,\n defaultValue: true,\n },\n noNamespaces: true,\n namingConvention: {\n typeNames: \"keep\",\n enumValues: \"keep\",\n },\n },\n };\n\n return {\n schema: \"\",\n ignoreNoDocuments: true, // for better experience with the watcher\n generates,\n };\n};\n"]}