Skip to content

Commit

Permalink
mega simplify and single tsconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
enisdenjo committed Oct 15, 2024
1 parent 3ddf50b commit dca2269
Show file tree
Hide file tree
Showing 26 changed files with 90 additions and 108 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"scripts": {
"build": "yarn workspaces foreach -A -p run build",
"check:format": "prettier --check .",
"check:type": "yarn tsc -b",
"check:type": "yarn tsc",
"format": "yarn check:format --write"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/gateway/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
},
"dependencies": {
"@commander-js/extra-typings": "^12.1.0",
"@graphql-hive/gateway-runtime": "^0.0.0",
"@graphql-mesh/cache-cfw-kv": "^0.102.6",
"@graphql-mesh/cache-localforage": "^0.102.6",
"@graphql-mesh/cache-redis": "^0.102.6",
Expand All @@ -60,7 +61,6 @@
"@graphql-mesh/plugin-prometheus": "^1.1.0",
"@graphql-mesh/plugin-rate-limit": "^0.102.6",
"@graphql-mesh/plugin-snapshot": "^0.102.6",
"@graphql-mesh/serve-runtime": "^1.1.0",
"@graphql-mesh/transport-http-callback": "^0.4.1",
"@graphql-mesh/transport-ws": "^0.3.7",
"@graphql-mesh/types": "^0.102.6",
Expand Down
1 change: 0 additions & 1 deletion packages/gateway/scripts/inject-version.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { readFile, writeFile } from 'node:fs/promises';
import { resolve } from 'node:path';
import { fileURLToPath, URL } from 'node:url';
// @ts-expect-error tsx will allow this to work
import pkg from '../package.json';

const version = process.argv[2] || pkg.version;
Expand Down
6 changes: 1 addition & 5 deletions packages/gateway/src/bin.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
#!/usr/bin/env node
import { DefaultLogger } from '@graphql-mesh/utils';
import {
enableModuleCachingIfPossible,
handleNodeWarnings,
run,
} from './cli.js';
import { enableModuleCachingIfPossible, handleNodeWarnings, run } from './cli';

// @inject-version globalThis.__VERSION__ here

Expand Down
18 changes: 9 additions & 9 deletions packages/gateway/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@ import {
InvalidArgumentError,
Option,
} from '@commander-js/extra-typings';
import type { InitializeData } from '@graphql-mesh/include/hooks';
import type { JWTAuthPluginOptions } from '@graphql-mesh/plugin-jwt-auth';
import type { OpenTelemetryMeshPluginOptions } from '@graphql-mesh/plugin-opentelemetry';
import type { PrometheusPluginOptions } from '@graphql-mesh/plugin-prometheus';
import type useMeshRateLimit from '@graphql-mesh/plugin-rate-limit';
import type {
GatewayConfigContext,
GatewayConfigProxy,
GatewayConfigSubgraph,
GatewayConfigSupergraph,
} from '@graphql-mesh/serve-runtime';
} from '@graphql-hive/gateway-runtime';
import type { InitializeData } from '@graphql-mesh/include/hooks';
import type { JWTAuthPluginOptions } from '@graphql-mesh/plugin-jwt-auth';
import type { OpenTelemetryMeshPluginOptions } from '@graphql-mesh/plugin-opentelemetry';
import type { PrometheusPluginOptions } from '@graphql-mesh/plugin-prometheus';
import useMeshRateLimit from '@graphql-mesh/plugin-rate-limit';
import type { KeyValueCache, Logger, YamlConfig } from '@graphql-mesh/types';
import { DefaultLogger } from '@graphql-mesh/utils';
import parseDuration from 'parse-duration';
import { addCommands } from './commands/index.js';
import { createDefaultConfigPaths } from './config.js';
import type { ServerConfig } from './server.js';
import { addCommands } from './commands/index';
import { createDefaultConfigPaths } from './config';
import type { ServerConfig } from './server';

export type GatewayCLIConfig = (
| GatewayCLISupergraphConfig
Expand Down
8 changes: 4 additions & 4 deletions packages/gateway/src/commands/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { AddCommand } from '../cli.js';
import { addCommand as addProxyCommand } from './proxy.js';
import { addCommand as addSubgraphCommand } from './subgraph.js';
import { addCommand as addSupergraphCommand } from './supergraph.js';
import type { AddCommand } from '../cli';
import { addCommand as addProxyCommand } from './proxy';
import { addCommand as addSubgraphCommand } from './subgraph';
import { addCommand as addSupergraphCommand } from './supergraph';

export const addCommands: AddCommand = (ctx, cli) => {
addSupergraphCommand(ctx, cli);
Expand Down
10 changes: 5 additions & 5 deletions packages/gateway/src/commands/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@ import cluster from 'node:cluster';
import {
createGatewayRuntime,
type GatewayConfigProxy,
} from '@graphql-mesh/serve-runtime';
} from '@graphql-hive/gateway-runtime';
import { isUrl, PubSub } from '@graphql-mesh/utils';
import {
defaultOptions,
type AddCommand,
type CLIContext,
type CLIGlobals,
type GatewayCLIConfig,
} from '../cli.js';
} from '../cli';
import {
getBuiltinPluginsFromConfig,
getCacheInstanceFromConfig,
loadConfig,
} from '../config.js';
import { startServerForRuntime } from '../server.js';
import { handleFork } from './handleFork.js';
} from '../config';
import { startServerForRuntime } from '../server';
import { handleFork } from './handleFork';

export const addCommand: AddCommand = (ctx, cli) =>
cli
Expand Down
10 changes: 5 additions & 5 deletions packages/gateway/src/commands/subgraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
createGatewayRuntime,
type GatewayConfigSubgraph,
type UnifiedGraphConfig,
} from '@graphql-mesh/serve-runtime';
} from '@graphql-hive/gateway-runtime';
import { isUrl, PubSub } from '@graphql-mesh/utils';
import { isValidPath } from '@graphql-tools/utils';
import {
Expand All @@ -14,14 +14,14 @@ import {
type CLIContext,
type CLIGlobals,
type GatewayCLIConfig,
} from '../cli.js';
} from '../cli';
import {
getBuiltinPluginsFromConfig,
getCacheInstanceFromConfig,
loadConfig,
} from '../config.js';
import { startServerForRuntime } from '../server.js';
import { handleFork } from './handleFork.js';
} from '../config';
import { startServerForRuntime } from '../server';
import { handleFork } from './handleFork';

export const addCommand: AddCommand = (ctx, cli) =>
cli
Expand Down
10 changes: 5 additions & 5 deletions packages/gateway/src/commands/supergraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
type GatewayGraphOSManagedFederationOptions,
type GatewayHiveCDNOptions,
type UnifiedGraphConfig,
} from '@graphql-mesh/serve-runtime';
} from '@graphql-hive/gateway-runtime';
import { isUrl, PubSub, registerTerminateHandler } from '@graphql-mesh/utils';
import { isValidPath } from '@graphql-tools/utils';
import {
Expand All @@ -17,14 +17,14 @@ import {
type CLIContext,
type CLIGlobals,
type GatewayCLIConfig,
} from '../cli.js';
} from '../cli';
import {
getBuiltinPluginsFromConfig,
getCacheInstanceFromConfig,
loadConfig,
} from '../config.js';
import { startServerForRuntime } from '../server.js';
import { handleFork } from './handleFork.js';
} from '../config';
import { startServerForRuntime } from '../server';
import { handleFork } from './handleFork';

export const addCommand: AddCommand = (ctx, cli) =>
cli
Expand Down
6 changes: 3 additions & 3 deletions packages/gateway/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import type {
GatewayConfig,
GatewayConfigContext,
GatewayPlugin,
} from '@graphql-mesh/serve-runtime';
} from '@graphql-hive/gateway-runtime';
import type { KeyValueCache, Logger } from '@graphql-mesh/types';
import type { GatewayCLIBuiltinPluginConfig } from './cli.js';
import type { ServerConfig } from './server.js';
import type { GatewayCLIBuiltinPluginConfig } from './cli';
import type { ServerConfig } from './server';

export const defaultConfigExtensions = [
'.ts',
Expand Down
4 changes: 2 additions & 2 deletions packages/gateway/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export * from './cli.js';
export * from '@graphql-mesh/serve-runtime';
export * from './cli';
export * from '@graphql-hive/gateway-runtime';
export { PubSub } from '@graphql-mesh/utils';
export * from '@graphql-mesh/plugin-jwt-auth';
export * from '@graphql-mesh/plugin-opentelemetry';
Expand Down
4 changes: 2 additions & 2 deletions packages/gateway/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { promises as fsPromises } from 'node:fs';
import { createServer as createHTTPServer, type Server } from 'node:http';
import { createServer as createHTTPSServer } from 'node:https';
import type { SecureContextOptions } from 'node:tls';
import type { GatewayRuntime } from '@graphql-mesh/serve-runtime';
import type { GatewayRuntime } from '@graphql-hive/gateway-runtime';
import type { Logger } from '@graphql-mesh/types';
import { createAsyncDisposable, getTerminateStack } from '@graphql-mesh/utils';
import { defaultOptions } from './cli.js';
import { defaultOptions } from './cli';

export interface ServerConfig {
/**
Expand Down
4 changes: 0 additions & 4 deletions packages/gateway/tsconfig.json

This file was deleted.

4 changes: 2 additions & 2 deletions packages/runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"engines": {
"node": ">=18.0.0"
},
"bin": "./dist/bin.js",
"main": "./dist/index.js",
"exports": {
".": {
Expand Down Expand Up @@ -74,7 +73,8 @@
"devDependencies": {
"@envelop/disable-introspection": "6.0.0",
"graphql-sse": "^2.5.3",
"html-minifier-terser": "7.2.0"
"html-minifier-terser": "7.2.0",
"pkgroll": "^2.5.0"
},
"sideEffects": false
}
36 changes: 18 additions & 18 deletions packages/runtime/src/createGatewayRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,34 +66,34 @@ import {
type YogaServerInstance,
} from 'graphql-yoga';
import type { GraphiQLOptions, PromiseOrValue } from 'graphql-yoga';
import { getProxyExecutor } from './getProxyExecutor.js';
import { getReportingPlugin } from './getReportingPlugin.js';
import { getProxyExecutor } from './getProxyExecutor';
import { getReportingPlugin } from './getReportingPlugin';
import {
getUnifiedGraphSDL,
handleUnifiedGraphConfig,
} from './handleUnifiedGraphConfig.js';
import landingPageHtml from './landing-page-html.js';
import { useChangingSchema } from './plugins/useChangingSchema.js';
import { useCompleteSubscriptionsOnDispose } from './plugins/useCompleteSubscriptionsOnDispose.js';
import { useCompleteSubscriptionsOnSchemaChange } from './plugins/useCompleteSubscriptionsOnSchemaChange.js';
import { useContentEncoding } from './plugins/useContentEncoding.js';
import { useCustomAgent } from './plugins/useCustomAgent.js';
import { useFetchDebug } from './plugins/useFetchDebug.js';
import { usePropagateHeaders } from './plugins/usePropagateHeaders.js';
import { useRequestId } from './plugins/useRequestId.js';
import { useSubgraphExecuteDebug } from './plugins/useSubgraphExecuteDebug.js';
import { useUpstreamCancel } from './plugins/useUpstreamCancel.js';
import { useWebhooks } from './plugins/useWebhooks.js';
import { defaultProductLogo } from './productLogo.js';
} from './handleUnifiedGraphConfig';
import landingPageHtml from './landing-page-html';
import { useChangingSchema } from './plugins/useChangingSchema';
import { useCompleteSubscriptionsOnDispose } from './plugins/useCompleteSubscriptionsOnDispose';
import { useCompleteSubscriptionsOnSchemaChange } from './plugins/useCompleteSubscriptionsOnSchemaChange';
import { useContentEncoding } from './plugins/useContentEncoding';
import { useCustomAgent } from './plugins/useCustomAgent';
import { useFetchDebug } from './plugins/useFetchDebug';
import { usePropagateHeaders } from './plugins/usePropagateHeaders';
import { useRequestId } from './plugins/useRequestId';
import { useSubgraphExecuteDebug } from './plugins/useSubgraphExecuteDebug';
import { useUpstreamCancel } from './plugins/useUpstreamCancel';
import { useWebhooks } from './plugins/useWebhooks';
import { defaultProductLogo } from './productLogo';
import type {
GatewayConfig,
GatewayConfigContext,
GatewayContext,
GatewayHiveCDNOptions,
GatewayPlugin,
UnifiedGraphConfig,
} from './types.js';
import { checkIfDataSatisfiesSelectionSet, defaultQueryText } from './utils.js';
} from './types';
import { checkIfDataSatisfiesSelectionSet, defaultQueryText } from './utils';

// TODO: this type export is not properly accessible from graphql-yoga
// "graphql-yoga/typings/plugins/use-graphiql.js" is an illegal path
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime/src/getProxyExecutor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type {
import { getOnSubgraphExecute } from '@graphql-mesh/fusion-runtime';
import type { Executor } from '@graphql-tools/utils';
import type { GraphQLSchema } from 'graphql';
import type { GatewayConfigContext, GatewayConfigProxy } from './types.js';
import type { GatewayConfigContext, GatewayConfigProxy } from './types';

export function getProxyExecutor<TContext extends Record<string, any>>({
config,
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime/src/getReportingPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type {
GatewayConfig,
GatewayConfigContext,
GatewayPlugin,
} from './types.js';
} from './types';

export function getReportingPlugin<TContext extends Record<string, any>>(
config: GatewayConfig<TContext>,
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime/src/handleUnifiedGraphConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
} from '@graphql-tools/utils';
import type { DocumentNode, GraphQLSchema } from 'graphql';
import { buildASTSchema, isSchema, parse, print } from 'graphql';
import type { GatewayConfigContext } from './types.js';
import type { GatewayConfigContext } from './types';

export type UnifiedGraphSchema = GraphQLSchema | DocumentNode | string;

Expand Down
12 changes: 6 additions & 6 deletions packages/runtime/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
export * from './createGatewayRuntime.js';
export type * from './types.js';
export * from './plugins/useCustomFetch.js';
export * from './plugins/useStaticFiles.js';
export * from './getProxyExecutor.js';
export * from './plugins/usePropagateHeaders.js';
export * from './createGatewayRuntime';
export type * from './types';
export * from './plugins/useCustomFetch';
export * from './plugins/useStaticFiles';
export * from './getProxyExecutor';
export * from './plugins/usePropagateHeaders';
export * from '@whatwg-node/disposablestack';
export type { ResolveUserFn, ValidateUserFn } from '@envelop/generic-auth';
export * from '@graphql-mesh/hmac-upstream-signature';
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime/src/plugins/useCustomFetch.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable import/no-extraneous-dependencies */
import type { MeshFetch } from '@graphql-mesh/types';
import type { GatewayPlugin } from '../types.js';
import type { GatewayPlugin } from '../types';

export function useCustomFetch(fetch: MeshFetch): GatewayPlugin {
return {
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime/src/plugins/useUpstreamCancel.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { GatewayPlugin } from '../types.js';
import type { GatewayPlugin } from '../types';

export function useUpstreamCancel(): GatewayPlugin {
return {
Expand Down
8 changes: 4 additions & 4 deletions packages/runtime/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ import type {
Plugin as YogaPlugin,
YogaServerOptions,
} from 'graphql-yoga';
import type { UnifiedGraphConfig } from './handleUnifiedGraphConfig.js';
import type { UseContentEncodingOpts } from './plugins/useContentEncoding.js';
import type { AgentFactory } from './plugins/useCustomAgent.js';
import { PropagateHeadersOpts } from './plugins/usePropagateHeaders.js';
import type { UnifiedGraphConfig } from './handleUnifiedGraphConfig';
import type { UseContentEncodingOpts } from './plugins/useContentEncoding';
import type { AgentFactory } from './plugins/useCustomAgent';
import { PropagateHeadersOpts } from './plugins/usePropagateHeaders';

export type { UnifiedGraphConfig };

Expand Down
9 changes: 0 additions & 9 deletions packages/runtime/tsconfig.json

This file was deleted.

10 changes: 0 additions & 10 deletions tsconfig.base.json

This file was deleted.

19 changes: 14 additions & 5 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
{
"references": [
{ "path": "packages/gateway" },
{ "path": "packages/runtime" }
],
"include": []
"extends": ["@tsconfig/strictest/tsconfig.json"],
"compilerOptions": {
// tsc only for type checking
"noEmit": true,
// pkgroll will take care of building, we use the most modern JS while coding
"module": "esnext",
"moduleResolution": "bundler",
"target": "esnext",
// packages
"paths": {
"@graphql-hive/gateway-runtime": ["./packages/runtime/src/index.ts"]
}
},
"include": ["packages/**/src", "packages/**/scripts"]
}
Loading

0 comments on commit dca2269

Please sign in to comment.