graphql-gene
Version:
Generates automatically an executable schema out of your ORM models
59 lines (58 loc) • 3.47 kB
TypeScript
import { GraphQLInterfaceType, GraphQLObjectType, GraphQLSchema, parseType, DocumentNode, GraphQLField, GraphQLNamedType, GraphQLOutputType } from 'graphql';
import { GeneContext } from 'graphql-gene/context';
import { AnyObject, FieldLines, GraphQLVarType, TypeDefLines } from '../types';
import { GeneConfig, GeneTypeConfig } from '../defineConfig';
export * from './extend';
type GraphQLOutputObjectType = GraphQLObjectType | GraphQLInterfaceType;
export declare function parseSchemaOption(schema: GraphQLSchema | DocumentNode | string | undefined, scalars?: string[]): GraphQLSchema | undefined;
export declare function lookDeepInSchema<TState>(options: {
each: (details: {
field: string;
fieldDef: GraphQLField<Record<string, unknown> | undefined, GeneContext, Record<string, unknown> | undefined>;
isList: boolean;
isNonNullable: boolean;
parentType: string;
parentTypeDef: GraphQLOutputObjectType;
state: TState;
type: string;
typeDef: GraphQLNamedType;
}) => TState | undefined;
schema: GraphQLSchema;
state?: TState;
}): void;
export declare function findAccurateTypeDef(type: GraphQLOutputType): GraphQLInterfaceType | import('graphql').GraphQLEnumType | import('graphql').GraphQLUnionType | import('graphql').GraphQLScalarType<unknown, unknown> | GraphQLObjectType<any, any> | undefined;
export declare function getGraphqlType(variable: string | number | boolean | string[] | number[] | boolean[]): string;
/**
* Inspired by
* @see https://github.com/graphql/graphql-js/issues/869#issuecomment-374351118
*/
export declare function printSchemaWithDirectives(schema: GraphQLSchema): string;
/** is using default Gene resolver if `resolver` or `args` option is set to "default" */
export declare function isUsingDefaultResolver(fieldConfig: AnyObject): boolean;
export declare function getDefaultTypeDefLinesObject(): TypeDefLines[0];
export declare function getDefaultFieldLinesObject(): FieldLines[0];
export declare function isObject<T>(variable: T): variable is T & object;
export declare function isEmptyObject<T extends object>(obj: T): boolean;
export declare function isArrayFieldConfig<T>(fieldConfigs: T): fieldConfigs is Extract<T, readonly string[]>;
export declare function isObjectFieldConfig<T>(fieldConfigs: T): fieldConfigs is Exclude<T, readonly string[]>;
export declare function normalizeFieldConfig<TConfig extends string | GeneTypeConfig<any, any, any, any>>(fieldConfig: TConfig): GeneTypeConfig;
export declare function isListType(type: ReturnType<typeof parseType>): boolean;
export declare function findTypeNameFromTypeNode(type: ReturnType<typeof parseType>): string;
export declare function getFieldDefinition(options: {
schema: GraphQLSchema;
parent: string;
field: string;
}): GraphQLField<any, any, any> | undefined;
/**
* Receives the full GraphQL return type and returns the type name as string.
*
* @example
* const returnTypeName = getReturnTypeName('[Foo!]!') // => 'Foo'
*/
export declare function getReturnTypeName(returnType: string): string;
export declare function getGeneConfigFromOptions<M>(options: {
model: M;
geneConfig?: GeneConfig<M>;
}): GeneConfig<M> | undefined;
export declare function isFieldIncluded<M>(geneConfig: GeneConfig<M> | undefined, fieldKey: string): boolean;
export declare function createTypeDefLines(typeDefLines: TypeDefLines, varType: GraphQLVarType, varName: string): void;