graphcool-cli-core
Version:
55 lines (54 loc) • 1.8 kB
TypeScript
import { ImportData, RelationTuple, RelationNode } from './types';
import { DocumentNode, ObjectTypeDefinitionNode, FieldDefinitionNode } from 'graphql';
export interface Mapping {
[]: {
[]: string;
};
}
export interface FieldsMap {
[]: FieldDefinitionNode;
}
export interface Types {
[]: {
definition: ObjectTypeDefinitionNode;
fields: FieldsMap;
requiredNonRelationScalarFieldNames: string[];
requiredNonRelationListFieldNames: string[];
allNonRelationListFieldNames: string[];
allNonRelationScalarFieldNames: string[];
};
}
export interface Enums {
[]: string[];
}
export declare class Validator {
typesString: string;
ast: DocumentNode;
types: Types;
enums: Enums;
mapping: Mapping;
validators: {
[]: (type: any) => boolean;
};
constructor(typesString: string);
validateImportData(data: ImportData): true;
validateNode(obj: any): true;
validateListNode(obj: any): true;
validateRelationNode(node: RelationNode): true;
validateRelationTuple(tuple: RelationTuple): true;
private checkFieldName(node);
private astToTypes(ast);
private astToEnums(ast);
private makeEnumValidators(enums);
private getFieldNames(definition, requiredOnly?, listsOnly?);
private resolveFieldName(typeName, fieldName);
private checkTypeName(obj);
private checkIdField(obj);
private checkRequiredFields(obj, listsOnly);
private checkUnknownFields(obj, includeLists);
private checkType(obj, listsOnly);
private validateValue(value, field, listsOnly);
private validateScalarValue(value, field);
private getDeepType(field);
private isList(field);
}