@graphql-mesh/cli 0.92.8-alpha-20240731132658-fac1161fec2605ac689485b79d6b571fd3cabea2 → 1.0.0-alpha-20240731125001-cbfa3d2b9c73d559c5290247c504e217b058639f

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/cjs/config.js CHANGED
@@ -7,9 +7,9 @@ const ajv_1 = tslib_1.__importDefault(require("ajv"));
7
7
  const cosmiconfig_1 = require("cosmiconfig");
8
8
  const config_1 = require("@graphql-mesh/config");
9
9
  const cross_helpers_1 = require("@graphql-mesh/cross-helpers");
10
+ const include_1 = require("@graphql-mesh/include");
10
11
  const types_1 = require("@graphql-mesh/types");
11
12
  const utils_1 = require("@graphql-mesh/utils");
12
- const defaultImportFn_js_1 = require("./defaultImportFn.js");
13
13
  function validateConfig(config, filepath, initialLoggerPrefix, throwOnInvalidConfig = false) {
14
14
  if (types_1.jsonSchema) {
15
15
  const ajv = new ajv_1.default({
@@ -44,7 +44,7 @@ function validateConfig(config, filepath, initialLoggerPrefix, throwOnInvalidCon
44
44
  }
45
45
  }
46
46
  async function findAndParseConfig(options) {
47
- const { configName = 'mesh', dir: configDir = '', initialLoggerPrefix = '🕸️ Mesh', importFn = defaultImportFn_js_1.defaultImportFn, ...restOptions } = options || {};
47
+ const { configName = 'mesh', dir: configDir = '', initialLoggerPrefix = '🕸️ Mesh', importFn = include_1.include, ...restOptions } = options || {};
48
48
  const dir = cross_helpers_1.path.isAbsolute(configDir) ? configDir : cross_helpers_1.path.join(cross_helpers_1.process.cwd(), configDir);
49
49
  const explorer = (0, cosmiconfig_1.cosmiconfig)(configName, {
50
50
  searchPlaces: [
@@ -76,7 +76,7 @@ async function findAndParseConfig(options) {
76
76
  validateConfig(config, results.filepath, initialLoggerPrefix, restOptions.throwOnInvalidConfig);
77
77
  return (0, config_1.processConfig)(config, { dir, initialLoggerPrefix, importFn, ...restOptions });
78
78
  }
79
- function customLoader(ext, importFn = defaultImportFn_js_1.defaultImportFn, initialLoggerPrefix = '🕸️ Mesh') {
79
+ function customLoader(ext, importFn = include_1.include, initialLoggerPrefix = '🕸️ Mesh') {
80
80
  const logger = new utils_1.DefaultLogger(initialLoggerPrefix).child('config');
81
81
  function loader(filepath, content) {
82
82
  if (cross_helpers_1.process.env) {
package/cjs/index.js CHANGED
@@ -7,6 +7,7 @@ const dotenv_1 = require("dotenv");
7
7
  const yargs_1 = tslib_1.__importDefault(require("yargs"));
8
8
  const helpers_1 = require("yargs/helpers");
9
9
  const cross_helpers_1 = require("@graphql-mesh/cross-helpers");
10
+ const include_1 = require("@graphql-mesh/include");
10
11
  const runtime_1 = require("@graphql-mesh/runtime");
11
12
  const store_1 = require("@graphql-mesh/store");
12
13
  const utils_1 = require("@graphql-mesh/utils");
@@ -17,7 +18,6 @@ const ts_artifacts_js_1 = require("./commands/ts-artifacts.js");
17
18
  Object.defineProperty(exports, "generateTsArtifacts", { enumerable: true, get: function () { return ts_artifacts_js_1.generateTsArtifacts; } });
18
19
  const config_js_1 = require("./config.js");
19
20
  Object.defineProperty(exports, "findAndParseConfig", { enumerable: true, get: function () { return config_js_1.findAndParseConfig; } });
20
- const defaultImportFn_js_1 = require("./defaultImportFn.js");
21
21
  const handleFatalError_js_1 = require("./handleFatalError.js");
22
22
  Object.defineProperty(exports, "handleFatalError", { enumerable: true, get: function () { return handleFatalError_js_1.handleFatalError; } });
23
23
  exports.DEFAULT_CLI_PARAMS = {
@@ -49,7 +49,7 @@ async function graphqlMesh(cliParams = exports.DEFAULT_CLI_PARAMS, args = (0, he
49
49
  coerce: (externalModules) => Promise.all(externalModules.map(moduleName => {
50
50
  const localModulePath = cross_helpers_1.path.resolve(baseDir, moduleName);
51
51
  const islocalModule = cross_helpers_1.fs.existsSync(localModulePath);
52
- return (0, defaultImportFn_js_1.defaultImportFn)(islocalModule ? localModulePath : moduleName);
52
+ return (0, include_1.include)(islocalModule ? localModulePath : moduleName);
53
53
  })),
54
54
  })
55
55
  .option('dir', {
@@ -186,7 +186,7 @@ export function createBuiltMeshHTTPHandler<TServerContext = {}>(): MeshHTTPHandl
186
186
  }
187
187
  cross_helpers_1.process.env.NODE_ENV = 'production';
188
188
  const mainModule = cross_helpers_1.path.join(builtMeshArtifactsPath, 'index');
189
- const builtMeshArtifacts = await (0, defaultImportFn_js_1.defaultImportFn)(mainModule);
189
+ const builtMeshArtifacts = await (0, include_1.include)(mainModule);
190
190
  const rawServeConfig = builtMeshArtifacts.rawServeConfig;
191
191
  const meshOptions = await builtMeshArtifacts.getMeshOptions();
192
192
  logger = meshOptions.logger;
@@ -212,7 +212,7 @@ export function createBuiltMeshHTTPHandler<TServerContext = {}>(): MeshHTTPHandl
212
212
  }
213
213
  const store = new store_1.MeshStore(cliParams.artifactsDir, new store_1.FsStoreStorageAdapter({
214
214
  cwd: baseDir,
215
- importFn: defaultImportFn_js_1.defaultImportFn,
215
+ importFn: include_1.include,
216
216
  fileType: 'ts',
217
217
  }), {
218
218
  readonly: false,
@@ -222,7 +222,7 @@ export function createBuiltMeshHTTPHandler<TServerContext = {}>(): MeshHTTPHandl
222
222
  const meshConfig = await (0, config_js_1.findAndParseConfig)({
223
223
  dir: baseDir,
224
224
  store,
225
- importFn: defaultImportFn_js_1.defaultImportFn,
225
+ importFn: include_1.include,
226
226
  ignoreAdditionalResolvers: true,
227
227
  artifactsDir: cliParams.artifactsDir,
228
228
  configName: cliParams.configName,
@@ -260,7 +260,7 @@ export function createBuiltMeshHTTPHandler<TServerContext = {}>(): MeshHTTPHandl
260
260
  const importedModulesSet = new Set();
261
261
  const importPromises = [];
262
262
  const importFn = (moduleId, noCache) => {
263
- const importPromise = (0, defaultImportFn_js_1.defaultImportFn)(moduleId)
263
+ const importPromise = (0, include_1.include)(moduleId)
264
264
  .catch(e => {
265
265
  if (e.message.includes('getter')) {
266
266
  return e;
package/esm/config.js CHANGED
@@ -2,9 +2,9 @@ import Ajv from 'ajv';
2
2
  import { cosmiconfig, defaultLoaders } from 'cosmiconfig';
3
3
  import { processConfig } from '@graphql-mesh/config';
4
4
  import { path, process } from '@graphql-mesh/cross-helpers';
5
+ import { include } from '@graphql-mesh/include';
5
6
  import { jsonSchema } from '@graphql-mesh/types';
6
7
  import { DefaultLogger, loadYaml } from '@graphql-mesh/utils';
7
- import { defaultImportFn } from './defaultImportFn.js';
8
8
  export function validateConfig(config, filepath, initialLoggerPrefix, throwOnInvalidConfig = false) {
9
9
  if (jsonSchema) {
10
10
  const ajv = new Ajv({
@@ -39,7 +39,7 @@ export function validateConfig(config, filepath, initialLoggerPrefix, throwOnInv
39
39
  }
40
40
  }
41
41
  export async function findAndParseConfig(options) {
42
- const { configName = 'mesh', dir: configDir = '', initialLoggerPrefix = '🕸️ Mesh', importFn = defaultImportFn, ...restOptions } = options || {};
42
+ const { configName = 'mesh', dir: configDir = '', initialLoggerPrefix = '🕸️ Mesh', importFn = include, ...restOptions } = options || {};
43
43
  const dir = path.isAbsolute(configDir) ? configDir : path.join(process.cwd(), configDir);
44
44
  const explorer = cosmiconfig(configName, {
45
45
  searchPlaces: [
@@ -71,7 +71,7 @@ export async function findAndParseConfig(options) {
71
71
  validateConfig(config, results.filepath, initialLoggerPrefix, restOptions.throwOnInvalidConfig);
72
72
  return processConfig(config, { dir, initialLoggerPrefix, importFn, ...restOptions });
73
73
  }
74
- function customLoader(ext, importFn = defaultImportFn, initialLoggerPrefix = '🕸️ Mesh') {
74
+ function customLoader(ext, importFn = include, initialLoggerPrefix = '🕸️ Mesh') {
75
75
  const logger = new DefaultLogger(initialLoggerPrefix).child('config');
76
76
  function loader(filepath, content) {
77
77
  if (process.env) {
package/esm/index.js CHANGED
@@ -2,6 +2,7 @@ import { config as dotEnvRegister } from 'dotenv';
2
2
  import yargs from 'yargs';
3
3
  import { hideBin } from 'yargs/helpers';
4
4
  import { fs, path as pathModule, process } from '@graphql-mesh/cross-helpers';
5
+ import { include } from '@graphql-mesh/include';
5
6
  import { getMesh } from '@graphql-mesh/runtime';
6
7
  import { FsStoreStorageAdapter, MeshStore } from '@graphql-mesh/store';
7
8
  import { DefaultLogger, pathExists, registerTerminateHandler, rmdirs, writeFile, } from '@graphql-mesh/utils';
@@ -9,7 +10,6 @@ import { printSchemaWithDirectives } from '@graphql-tools/utils';
9
10
  import { serveMesh } from './commands/serve/serve.js';
10
11
  import { generateTsArtifacts } from './commands/ts-artifacts.js';
11
12
  import { findAndParseConfig } from './config.js';
12
- import { defaultImportFn } from './defaultImportFn.js';
13
13
  import { handleFatalError } from './handleFatalError.js';
14
14
  export { generateTsArtifacts, serveMesh, findAndParseConfig, handleFatalError };
15
15
  export const DEFAULT_CLI_PARAMS = {
@@ -41,7 +41,7 @@ export async function graphqlMesh(cliParams = DEFAULT_CLI_PARAMS, args = hideBin
41
41
  coerce: (externalModules) => Promise.all(externalModules.map(moduleName => {
42
42
  const localModulePath = pathModule.resolve(baseDir, moduleName);
43
43
  const islocalModule = fs.existsSync(localModulePath);
44
- return defaultImportFn(islocalModule ? localModulePath : moduleName);
44
+ return include(islocalModule ? localModulePath : moduleName);
45
45
  })),
46
46
  })
47
47
  .option('dir', {
@@ -178,7 +178,7 @@ export function createBuiltMeshHTTPHandler<TServerContext = {}>(): MeshHTTPHandl
178
178
  }
179
179
  process.env.NODE_ENV = 'production';
180
180
  const mainModule = pathModule.join(builtMeshArtifactsPath, 'index');
181
- const builtMeshArtifacts = await defaultImportFn(mainModule);
181
+ const builtMeshArtifacts = await include(mainModule);
182
182
  const rawServeConfig = builtMeshArtifacts.rawServeConfig;
183
183
  const meshOptions = await builtMeshArtifacts.getMeshOptions();
184
184
  logger = meshOptions.logger;
@@ -204,7 +204,7 @@ export function createBuiltMeshHTTPHandler<TServerContext = {}>(): MeshHTTPHandl
204
204
  }
205
205
  const store = new MeshStore(cliParams.artifactsDir, new FsStoreStorageAdapter({
206
206
  cwd: baseDir,
207
- importFn: defaultImportFn,
207
+ importFn: include,
208
208
  fileType: 'ts',
209
209
  }), {
210
210
  readonly: false,
@@ -214,7 +214,7 @@ export function createBuiltMeshHTTPHandler<TServerContext = {}>(): MeshHTTPHandl
214
214
  const meshConfig = await findAndParseConfig({
215
215
  dir: baseDir,
216
216
  store,
217
- importFn: defaultImportFn,
217
+ importFn: include,
218
218
  ignoreAdditionalResolvers: true,
219
219
  artifactsDir: cliParams.artifactsDir,
220
220
  configName: cliParams.configName,
@@ -252,7 +252,7 @@ export function createBuiltMeshHTTPHandler<TServerContext = {}>(): MeshHTTPHandl
252
252
  const importedModulesSet = new Set();
253
253
  const importPromises = [];
254
254
  const importFn = (moduleId, noCache) => {
255
- const importPromise = defaultImportFn(moduleId)
255
+ const importPromise = include(moduleId)
256
256
  .catch(e => {
257
257
  if (e.message.includes('getter')) {
258
258
  return e;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-mesh/cli",
3
- "version": "0.92.8-alpha-20240731132658-fac1161fec2605ac689485b79d6b571fd3cabea2",
3
+ "version": "1.0.0-alpha-20240731125001-cbfa3d2b9c73d559c5290247c504e217b058639f",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
6
  "graphql": "*"
@@ -14,7 +14,8 @@
14
14
  "@graphql-codegen/typescript-resolvers": "^4.0.0",
15
15
  "@graphql-mesh/config": "^0.101.6",
16
16
  "@graphql-mesh/cross-helpers": "^0.4.4",
17
- "@graphql-mesh/http": "0.100.7-alpha-20240731132658-fac1161fec2605ac689485b79d6b571fd3cabea2",
17
+ "@graphql-mesh/http": "^0.100.6",
18
+ "@graphql-mesh/include": "1.0.0-alpha-20240731125001-cbfa3d2b9c73d559c5290247c504e217b058639f",
18
19
  "@graphql-mesh/runtime": "^0.100.6",
19
20
  "@graphql-mesh/store": "^0.99.5",
20
21
  "@graphql-mesh/types": "^0.99.5",
@@ -26,7 +27,6 @@
26
27
  "dotenv": "^16.0.3",
27
28
  "graphql-import-node": "^0.0.5",
28
29
  "graphql-ws": "^5.12.1",
29
- "jiti": "^1.21.6",
30
30
  "json-bigint-patch": "^0.0.8",
31
31
  "json5": "^2.2.3",
32
32
  "mkdirp": "^3.0.0",
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.defaultImportFn = void 0;
4
- const tslib_1 = require("tslib");
5
- const jiti_1 = tslib_1.__importDefault(require("jiti"));
6
- let jiti;
7
- function getOrCreateImportFn() {
8
- if (!jiti) {
9
- // we instantiate on demand because sometimes jiti is not used
10
- jiti = (0, jiti_1.default)(__filename);
11
- }
12
- return id => jiti.import(id, {});
13
- }
14
- const defaultImportFn = async (id) => {
15
- let module = await getOrCreateImportFn()(id);
16
- if (module.default != null) {
17
- module = module.default;
18
- }
19
- if (typeof module === 'object' && module != null) {
20
- const prototypeOfObject = Object.getPrototypeOf(module);
21
- if (prototypeOfObject == null || prototypeOfObject === Object.prototype) {
22
- const normalizedVal = {};
23
- for (const key in module) {
24
- normalizedVal[key] = module[key];
25
- }
26
- return normalizedVal;
27
- }
28
- }
29
- return module;
30
- };
31
- exports.defaultImportFn = defaultImportFn;
@@ -1,26 +0,0 @@
1
- import createJITI from 'jiti';
2
- let jiti;
3
- function getOrCreateImportFn() {
4
- if (!jiti) {
5
- // we instantiate on demand because sometimes jiti is not used
6
- jiti = createJITI(__filename);
7
- }
8
- return id => jiti.import(id, {});
9
- }
10
- export const defaultImportFn = async (id) => {
11
- let module = await getOrCreateImportFn()(id);
12
- if (module.default != null) {
13
- module = module.default;
14
- }
15
- if (typeof module === 'object' && module != null) {
16
- const prototypeOfObject = Object.getPrototypeOf(module);
17
- if (prototypeOfObject == null || prototypeOfObject === Object.prototype) {
18
- const normalizedVal = {};
19
- for (const key in module) {
20
- normalizedVal[key] = module[key];
21
- }
22
- return normalizedVal;
23
- }
24
- }
25
- return module;
26
- };
@@ -1,2 +0,0 @@
1
- import type { ImportFn } from '@graphql-mesh/types';
2
- export declare const defaultImportFn: ImportFn;
@@ -1,2 +0,0 @@
1
- import type { ImportFn } from '@graphql-mesh/types';
2
- export declare const defaultImportFn: ImportFn;