graphql-to-mongodb
graphql-to-mongodb copied to clipboard
Fixes "Maximum call stack size exceeded" exception in Sort
Currently sort causes kind on an endless loop. Value can't be a number. It is either ASC, DESC or an when it is a nested sort.
Hi,
Thanks for showing interest in the package.
The underlying values of the SortType
enum are indeed numeric, as can be seen here (near the end of the file).
If you're getting a string type arg in the resolver, then I think the issue is similar to #47 #48. Did you use (graphql-tools
/apollo
)
You are right. This part in makeExcecutableSchema was missing and caused the SortType to be string: const cachedTypeKeys: string[] = Object.keys(typesCache);
for (const key of cachedTypeKeys) { const enumType = typesCache[key];
if (!isEnumType(enumType)) {
continue;
}
if (config.resolvers) {
config.resolvers[key] = enumType.getValues().reduce((resolver: IResolvers, value: GraphQLEnumValue) => {
resolver[value.name] = value.value;
return resolver;
}, {});
}
} Anyway, to make it more fault tolerance the check clould also be value !== object. In this case Sort would work with number and string.