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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | 19x 19x 19x 19x 148x 148x 1x 147x 96x 51x 4x 47x 2x 45x 3x 42x 20x 22x 3x 19x 1x 18x 6x 12x 19x 4x 1x 3x 3x 3x 3x 2x 2x 4x 19x | import { isType, GraphQLType, GraphQLList, GraphQLNonNull } from 'graphql'; import { Thunk } from '~/services/types'; import { objectTypeRegistry, compileObjectType, inputObjectTypeRegistry, compileInputObjectType, enumsRegistry, unionRegistry, } from '~/domains'; import { parseNativeTypeToGraphQL, isParsableScalar } from './parseNative'; export function resolveType(input: any, allowThunk = true): GraphQLType { if (isType(input)) { return input; } if (isParsableScalar(input)) { return parseNativeTypeToGraphQL(input); } if (Array.isArray(input)) { return resolveListType(input); } if (enumsRegistry.has(input)) { return enumsRegistry.get(input); } if (unionRegistry.has(input)) { return unionRegistry.get(input)(); } if (objectTypeRegistry.has(input)) { return compileObjectType(input); } if (inputObjectTypeRegistry.has(input)) { return compileInputObjectType(input); } if (input === Promise) { Ireturn; } if (!allowThunk || typeof input !== 'function') { return; } E return resolveType(input(), false); } function resolveListType(input: any[]): GraphQLType { if (input.length !== 1) { return; } const [itemType] = input; const resolvedItemType = resolveType(itemType); if (!resolvedItemType) { return; } return new GraphQLList(new GraphQLNonNull(resolvedItemType)); } export function resolveTypesList(types: Thunk<any[]>): GraphQLType[] { if (Array.isArray(types)) { return types.map(type => { return resolveType(type); }); } return types().map(type => { return resolveType(type); }); } |