Skip to content

Conversation

@ltwlf
Copy link

@ltwlf ltwlf commented Sep 20, 2019

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.

@yoavkarako
Copy link
Collaborator

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)

@ltwlf
Copy link
Author

ltwlf commented Sep 21, 2019

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.

@ltwlf ltwlf closed this Nov 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants