You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If the recipe resolver is written in such a way that database automatically loads all relations then the following query will succeed:
query {
recipes {
id,
ingredients {
id
}
author {
id
}
}
}
However if it does not have a field resolver for author, the following query would fail:
query {
ingredients {
id,
recipes {
id
author {
id
}
}
}
}
How can I write a test that checks if the necessary field resolvers have been implemented? The test would ideally not depend on the ingredients query - else I could just check if that query succeeds but that would be too dependent on other things. Also, is there a way in which the test can detect automatically which fields would need a field resolver, e.g. by understanding when a field refers to another ObjectType?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I would like to write a test in jest that checks if the all the field resolvers have been implemented.
Lets assume I have the following schema:
If the recipe resolver is written in such a way that database automatically loads all relations then the following query will succeed:
However if it does not have a field resolver for author, the following query would fail:
How can I write a test that checks if the necessary field resolvers have been implemented? The test would ideally not depend on the ingredients query - else I could just check if that query succeeds but that would be too dependent on other things. Also, is there a way in which the test can detect automatically which fields would need a field resolver, e.g. by understanding when a field refers to another ObjectType?
Beta Was this translation helpful? Give feedback.
All reactions