Skip to content

Commit

Permalink
fix(cli): handle TServerContext correctly in `createBuiltMeshHTTPHa…
Browse files Browse the repository at this point in the history
…ndler` (#5153)
  • Loading branch information
ardatan authored Feb 16, 2023
1 parent 9d62da4 commit 5c19f8d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 17 deletions.
6 changes: 6 additions & 0 deletions .changeset/smooth-balloons-scream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@graphql-mesh/types': patch
'@graphql-mesh/cli': patch
---

Fix `createBuiltMeshHTTPHandler`'s context generic
32 changes: 16 additions & 16 deletions packages/cli/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { findAndParseConfig } from './config.js';
import { getMesh, GetMeshOptions, ServeMeshOptions } from '@graphql-mesh/runtime';
import { generateTsArtifacts } from './commands/ts-artifacts.js';
import { serveMesh } from './commands/serve/serve.js';
import { fs, path as pathModule, process } from '@graphql-mesh/cross-helpers';
import { FsStoreStorageAdapter, MeshStore } from '@graphql-mesh/store';
import { writeFile, pathExists, rmdirs, DefaultLogger, defaultImportFn } from '@graphql-mesh/utils';
import { handleFatalError } from './handleFatalError.js';
import { config as dotEnvRegister } from 'dotenv';
import JSON5 from 'json5';
import { register as tsNodeRegister } from 'ts-node';
import { register as tsConfigPathsRegister } from 'tsconfig-paths';
import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';
import { fs, path as pathModule, process } from '@graphql-mesh/cross-helpers';
import { getMesh, GetMeshOptions, ServeMeshOptions } from '@graphql-mesh/runtime';
import { FsStoreStorageAdapter, MeshStore } from '@graphql-mesh/store';
import { Logger, YamlConfig } from '@graphql-mesh/types';
import { register as tsNodeRegister } from 'ts-node';
import { register as tsConfigPathsRegister } from 'tsconfig-paths';
import { config as dotEnvRegister } from 'dotenv';
import { defaultImportFn, DefaultLogger, pathExists, rmdirs, writeFile } from '@graphql-mesh/utils';
import { printSchemaWithDirectives } from '@graphql-tools/utils';
import JSON5 from 'json5';
import { serveMesh } from './commands/serve/serve.js';
import { generateTsArtifacts } from './commands/ts-artifacts.js';
import { findAndParseConfig } from './config.js';
import { handleFatalError } from './handleFatalError.js';

export { generateTsArtifacts, serveMesh, findAndParseConfig, handleFatalError };

Expand Down Expand Up @@ -181,8 +181,8 @@ export function getMeshOptions() {
});
}
export function createBuiltMeshHTTPHandler(): MeshHTTPHandler<MeshContext> {
return createMeshHTTPHandler<MeshContext>({
export function createBuiltMeshHTTPHandler<TServerContext = {}>(): MeshHTTPHandler<TServerContext> {
return createMeshHTTPHandler<TServerContext>({
baseDir,
getBuiltMesh: ${cliParams.builtMeshFactoryName},
rawServeConfig: ${JSON.stringify(meshConfig.config.serve)},
Expand Down Expand Up @@ -385,8 +385,8 @@ export function createBuiltMeshHTTPHandler(): MeshHTTPHandler<MeshContext> {
`import { createMeshHTTPHandler, MeshHTTPHandler } from '@graphql-mesh/http';`,
);
meshConfig.codes.add(`
export function createBuiltMeshHTTPHandler(): MeshHTTPHandler<MeshContext> {
return createMeshHTTPHandler<MeshContext>({
export function createBuiltMeshHTTPHandler<TServerContext = {}>(): MeshHTTPHandler<TServerContext> {
return createMeshHTTPHandler<TServerContext>({
baseDir,
getBuiltMesh: ${cliParams.builtMeshFactoryName},
rawServeConfig: ${JSON.stringify(meshConfig.config.serve)},
Expand Down
1 change: 0 additions & 1 deletion packages/types/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1970,7 +1970,6 @@ export interface PrometheusConfig {
fetch?: boolean | string;
fetchRequestHeaders?: boolean;
fetchResponseHeaders?: boolean;

/**
* Any of: Boolean, String
*/
Expand Down

0 comments on commit 5c19f8d

Please sign in to comment.