UNPKG

@newmo/graphql-fake-server

Version:
84 lines 2.46 kB
import { type MockFactory } from "@newmo/graphql-fake-core"; import { type GraphQLSchema } from "graphql/index.js"; import type { RequiredFakeServerConfig } from "./config.js"; import { type LogLevel } from "./logger.js"; export type CreateFakeServerOptions = RequiredFakeServerConfig; type FakeServerInternal = { mockFactories: Record<string, MockFactory>; emptyListFields: Map<string, Set<string>>; schema: GraphQLSchema; ports: { fakeServer: number; apolloServer: number; }; maxQueryDepth: number; maxRegisteredSequences: number; listLength: number; logLevel: LogLevel; allowedCORSOrigins: string[]; allowedHosts: string[] | "auto"; }; /** * Generate allowed hosts based on server port and CORS origins */ export declare const generateAllowedHosts: ({ serverPort, allowedCORSOrigins, allowedHosts, }: { serverPort: number; allowedCORSOrigins?: string[]; allowedHosts?: string[] | "auto"; }) => Set<string>; export type ConditionRule = { type: "always"; } | { type: "variables"; value: Record<string, unknown>; }; export type CalledResult = { requestTimestamp: number; request: { headers: Record<string, string>; body: Record<string, unknown>; }; response: { status: number; headers: Record<string, string>; body: unknown; }; }; export type CalledResultResponse = { ok: boolean; data: CalledResult[]; }; export type RegisterSequenceNetworkError = { type: "network-error"; operationName: string; responseStatusCode: number; errors: Record<string, unknown>[]; requestCondition: ConditionRule; }; export type RegisterSequenceOperation = { type: "operation"; operationName: string; data: Record<string, unknown>; requestCondition: ConditionRule; }; export type RegisterSequenceOptions = RegisterSequenceNetworkError | RegisterSequenceOperation; export declare const createFakeServer: (options: CreateFakeServerOptions) => Promise<{ start: () => Promise<{ urls: { fakeServer: string; apolloServer: string; }; }>; stop: () => void; }>; export declare const createFakeServerInternal: (options: FakeServerInternal) => Promise<{ start: () => Promise<{ urls: { fakeServer: string; apolloServer: string; }; }>; stop: () => void; }>; export {}; //# sourceMappingURL=server.d.ts.map