Open MarkLyck opened 2 years ago
It's not pretty, but I found this workaround.
const mocks = {
SiteCounts: () => ({
crm: {
sitesConnect: (_root, _args, _context, info) => {
if (info.path.key === 'sites') {
return { totalCount: 2 };
} else if (info.path.key === 'activeSites') {
return { totalCount: 1 };
}
}),
},
}),
};
Funny enough I ran into this issue again 2 years later and found my old ticket, Thanks @canac that worked!
This mocking library is fantastic (although it sadly looks abandoned?), non-the-less it's the only functional dynamic mocks library I've found that still works for the most part.
I did find that it has issues with queries that use aliases though.
Take this query which works just fine.
I can mock it lik this:
but if I add an alias to it like this:
I can no longer mock it :(
Doesn't work, and the original
sitesConnection
mock would override both parts of the query.I haven't found any other issues, or any mention in the code of
alias
so I assume this was just never implemented.But with the last update over 9 months ago, I'm guessing this project is dead? But I thought I'd create the ticket anyway just in case.