@graphql-tools/executor
Version:
Fork of GraphQL.js' execute function
18 lines (17 loc) • 557 B
JavaScript
import { orList } from './formatList.js';
const MAX_SUGGESTIONS = 5;
/** @internal */
export function didYouMean(firstArg, secondArg) {
const [subMessage, suggestions] = secondArg
? [firstArg, secondArg]
: [undefined, firstArg];
if (suggestions.length === 0) {
return '';
}
let message = ' Did you mean ';
if (subMessage != null) {
message += subMessage + ' ';
}
const suggestionList = orList(suggestions.slice(0, MAX_SUGGESTIONS).map(x => `"${x}"`));
return message + suggestionList + '?';
}