cashay icon indicating copy to clipboard operation
cashay copied to clipboard

minimizedQueryString is undefined

Open theobat opened this issue 8 years ago • 3 comments
trafficstars

hey @mattkrick, two things:

  • Are you interested in a PR that actually raises an error here (or is there any particular reason not to raise an error ?): (been strugguling with this silently failing)
// Cashay.js#L351
    const minimizedQueryString = printMinimalQuery(operation, idFieldName, variables, op, schema);
    console.log('query server',minimizedQueryString)

    // bail if we can't do anything with the variables that we were given
    if (!minimizedQueryString) {
      // TODO set status or error?
      return;
    }
  • Do you have any hint/help to understand why minimizedQueryString is undefined ? I believe it is related to my graphqlSchema but I'm still searching what's happening under the hood

theobat avatar Jan 25 '17 15:01 theobat

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 !)

theobat avatar Jan 25 '17 15:01 theobat

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!

mattkrick avatar Feb 15 '17 00:02 mattkrick

@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 ?

theobat avatar Feb 15 '17 13:02 theobat