mattkrick / cashay

:moneybag: Relay for the rest of us :moneybag:
MIT License
453 stars 28 forks source link

minimizedQueryString is undefined #160

Open theobat opened 7 years ago

theobat commented 7 years ago

hey @mattkrick, two things:

theobat commented 7 years ago

Ok so the problem was I only had one entry in my variables object when requesting cashay.query(...) And this variable was "undefined" at the time I was doing my query. What happens in that case is that when a variable is missing to query the server cashay removes this variable to find out which endpoint to take. Seemingly, the problem is that when you remove the only existing (not quite, let's say expected) variable cashay fails silently and never calls the server.

It's not a bug of cashay (the variable should not have been null on my end, that was the bug) but I would definitely add a test case and a proper error message in that case (when I'm done figuring everything out !)

mattkrick commented 7 years ago

ah, sorry for not responding to this...

so cashay allows for multi-part queries. for example, part 1 is getting a list of posts, part 2 is getting the comments for each post. How it does that is by seeing if the variable is undefined. so on first pass, the variable is undefined, so it ignores that part. when the variable is something useful (provided by the response of the first query) then it knows it can proceed to request the second part.

hope that makes sense!

theobat commented 7 years ago

@mattkrick thanks for your answer ! It does make sense but I'm not sure how we actually do the multi part query (and where it makes clear sense). There should be a mean to detect the number of part in the query and raise an error if minimizedQueryString is null and partNumber === 1 no ?