@newmo/graphql-fake-server
Version:
GraphQL fake server for testing
88 lines • 2.81 kB
TypeScript
import type { RawConfig } from "@newmo/graphql-fake-core";
import type { LogLevel } from "./logger.js";
/**
* Configuration for the fake server.
*/
export type FakeServerConfig = {
/**
* The path to the GraphQL schema file from cwd.
*/
schemaFilePath: string;
/**
* The ports for the fake server and Apollo Server.
*/
ports?: {
/**
* Fake Server port.
* Default is 4000.
*/
fakeServer?: number | undefined;
/**
* Apollo Server port.
* It provides the GraphQL Playground.
* Default is 4002.
*/
apolloServer?: number | undefined;
} | undefined;
/**
* The maximum number of registered sequences.
* Default is 1000.
*/
maxRegisteredSequences?: number | undefined;
/**
* The maximum number of depth of field recursion.
* Default is 9.
*/
maxFieldRecursionDepth?: RawConfig["maxFieldRecursionDepth"] | undefined;
/**
* The maximum number of depth of complexity of query
* this value should be maxFieldRecursionDepth + 1
* Default is 10
*/
maxQueryDepth?: number | undefined;
/**
* Default values for scalar types.
*/
defaultValues?: RawConfig["defaultValues"] | undefined;
/**
* Log level: "debug", "info", "warn", "error"
* If you want to see the debug logs, set the logLevel to "debug".
* Default is "info".
*/
logLevel?: LogLevel | undefined;
/**
* Additional origins to allow for CORS requests.
* By default, only localhost and private IP ranges are allowed.
* This option allows you to specify additional origins to accept.
*/
allowedCORSOrigins?: string[] | undefined;
};
export type RequiredFakeServerConfig = {
schemaFilePath: string;
ports: {
fakeServer: number;
apolloServer: number;
};
maxRegisteredSequences: number;
maxFieldRecursionDepth: number;
maxQueryDepth: number;
defaultValues: RawConfig["defaultValues"];
logLevel: LogLevel;
allowedCORSOrigins: string[];
};
export declare const normalizeFakeServerConfig: (config: FakeServerConfig) => RequiredFakeServerConfig;
export declare const validateFakeServerConfig: (config: FakeServerConfig) => FakeServerConfig;
/**
* Load the fake server configuration from the file.
* @param configPath
*/
export declare const loadConfig: (cwd: string, configPath: string) => Promise<RequiredFakeServerConfig>;
/**
* Load the fake server configuration from the CLI flags.
* @param cliFlag
*/
export declare const loadFakeServerConfigFromCLI: ({ schemaFilePath, logLevel, }: {
schemaFilePath?: string | undefined;
logLevel?: LogLevel | undefined;
}) => RequiredFakeServerConfig;
//# sourceMappingURL=config.d.ts.map