# 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
    3920x
    20x
    20x

    157x

    20x

    105x
    75x

    30x
    17x

    13x
    13x

    20x

    90x

    90x
    90x
    52x

    38x
    38x

    20x

     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;
    }