nikitastupin / clairvoyance

Obtain GraphQL API schema even if the introspection is disabled
Apache License 2.0
967 stars 87 forks source link

How apollo-server suggestions works? #2

Closed nikitastupin closed 1 year ago

nikitastupin commented 3 years ago

Following document returns following suggestions:

mutation { setNameFor }
Cannot query field \"setNameFor\" on type \"Mutation\". Did you mean \"setNameForHome\", \"setNameForCamera\", or \"setNameForHomeSensor\"?

However similar document returns less suggestions:

mutation { setName }
Cannot query field \"setName\" on type \"Mutation\". Did you mean \"setNameForHome\"?

If we would know the algorithm apollo-server uses for suggestion generation we'd potentially speed up guessing of fields, arguments and so on.

nikitastupin commented 3 years ago

It looks like suggestions implemented in underlying graphql-js library. The actual algorithm implemented in suggestionList() function.