Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minimizedQueryString is undefined #160

Open
theobat opened this issue Jan 25, 2017 · 3 comments
Open

minimizedQueryString is undefined #160

theobat opened this issue Jan 25, 2017 · 3 comments

Comments

@theobat
Copy link
Contributor

theobat commented Jan 25, 2017

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
Copy link
Contributor Author

theobat commented Jan 25, 2017

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
Copy link
Owner

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
Copy link
Contributor Author

theobat commented Feb 15, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants