@dataql/node
Version:
DataQL core SDK for unified data management with MongoDB and GraphQL - Production Multi-Cloud Ready
56 lines (55 loc) • 1.95 kB
TypeScript
import { GraphQLScalarType, GraphQLFieldConfig } from "graphql";
/**
* Custom GraphQL Scalars for MongoDB BSON types:
* - Decimal128: GraphQLDecimal128
* - Long: GraphQLLong
* - BinData: GraphQLBinData
* - Timestamp: GraphQLTimestamp
* - Regex: GraphQLRegex
* - DBPointer: GraphQLDBPointer
* - JavaScript: GraphQLJavaScript
* - MinKey/MaxKey: GraphQLMinKey/GraphQLMaxKey
* - Undefined: GraphQLUndefined
* - Null: GraphQLNull
*
* ObjectId is mapped to GraphQLID.
*/
export declare const GraphQLDecimal128: GraphQLScalarType<unknown, unknown>;
export declare const GraphQLLong: GraphQLScalarType<unknown, unknown>;
export declare const GraphQLTimestamp: GraphQLScalarType<unknown, unknown>;
export declare const typeToGraphQL: Record<string, any>;
export declare function schemaObjectToGraphQLFields(schema: any): Record<string, GraphQLFieldConfig<any, any>>;
export declare function normalizeField(field: any, isRoot?: boolean, visitedSchemas?: Set<unknown>): any;
export declare function normalizeSchemaObject(schemaObject: Record<string, any>, visitedSchemas?: Set<unknown>): {
[k: string]: any;
};
export declare function collection(name: string, schemaObject: any, options?: {
indexes?: {
[key: string]: 1 | -1;
}[];
}): SchemaDefinition;
type PrimitiveMap = {
ID: string;
String: string;
Int: number;
Decimal: number;
Boolean: boolean;
Date: string;
Number: number;
};
export type SchemaToType<S> = S extends keyof PrimitiveMap ? PrimitiveMap[S] : S extends (infer U)[] ? SchemaToType<U>[] : S extends object ? {
[K in keyof S]: SchemaToType<S[K]>;
} : never;
export declare const ID = "ID";
export declare const String = "String";
export declare const Boolean = "Boolean";
export declare const Money = "Decimal";
export interface SchemaDefinition {
name: string;
collection: string;
schemaObject: any;
indexes?: {
[key: string]: 1 | -1;
}[];
}
export {};