UNPKG

@nestjs/graphql

Version:

Nest - modern, fast, powerful node.js web framework (@graphql)

19 lines (18 loc) 977 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.normalizeResolverArgs = normalizeResolverArgs; const graphql_1 = require("graphql"); function normalizeResolverArgs(args) { // Reference resolver args don't have args argument (3 args instead of 4) const isReferenceResolver = args.length === 3; // Resolve type args don't have args argument and the last argument is the parent object type const isResolveType = !isReferenceResolver && (0, graphql_1.isType)(args[args.length - 1]); // Only create a new array when we need to insert undefined at position 1 // This avoids array allocation for the common 4-argument case if (isReferenceResolver || isResolveType) { // Insert undefined at position 1: [root, ctx, info] -> [root, undefined, ctx, info] return [args[0], undefined, args[1], args[2], args[3]]; } // Return original array for the common case (no mutation needed) return args; }