All files / services/utils/gql/types parseNative.ts

95% Statements 19/20
80% Branches 8/10
100% Functions 3/3
95% Lines 19/20

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 26 27 28 29 30 31 32 33 34 35 36 37 38 3919x 19x 19x   147x   19x   96x 72x   24x 17x   7x 7x     19x   85x     85x 85x 47x   38x 38x   19x                
import {
  GraphQLString,
  GraphQLFloat,
  GraphQLBoolean,
  GraphQLScalarType,
} from 'graphql';
import 'reflect-metadata';
export type ParsableScalar = String | Number | Boolean;
 
export function isParsableScalar(input: any): input is ParsableScalar {
  return [String, Number, Boolean].includes(input);
}
 
export function parseNativeTypeToGraphQL(input: any): GraphQLScalarType {
  ifE (input === String) {
    return GraphQLString;
  }
  if (input === Number) {
    return GraphQLFloat;
  }
  ifI (input === Boolean) {
    return GraphQLBoolean;
  }
}
 
export function inferTypeByTarget(target: Function, key?: string) {
  if (!key) {
    return Reflect.getMetadata('design:type', target);
  }
 
  const returnType = Reflect.getMetadata('design:returntype', target, key);
  if (returnType) {
    return returnType;
  }
 
  const type = Reflect.getMetadata('design:type', target, key);
  return type;
}