All files / domains/field index.ts

75% Statements 18/24
50% Branches 3/6
66.67% Functions 2/3
78.26% Lines 18/23
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 269x               9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x   44x 44x 44x  
import { fieldsRegistry, FieldInnerConfig, queryFieldsRegistry } from './registry';

export { FieldInnerConfig, fieldsRegistry, queryFieldsRegistry } from './registry';
export { compileAllFields, compileFieldConfig } from './compiler';
import { compileFieldConfig } from './compiler';
export { isQueryField } from './services';
export { FieldError } from './error';
 
interface FieldOptions {
  description?: string;
  type?: any;
  name?: string;
}
 
export function Field(options?: FieldOptions): PropertyDecorator {
  return (targetInstance: Object, fieldName: string) => {
    const finalConfig: FieldInnerConfig = {
      property: fieldName,
      name: fieldName,
      ...options,
    };
 
    fieldsRegistry.set(targetInstance.constructor, fieldName, finalConfig);
  };
}