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

Delegating to remote schema does not forward identical query? #633

Closed
kdojeteri opened this issue Feb 13, 2018 · 2 comments
Closed

Delegating to remote schema does not forward identical query? #633

kdojeteri opened this issue Feb 13, 2018 · 2 comments

Comments

@kdojeteri
Copy link

I'm having trouble stitching my schema to my former API written in Youshido\GraphQL. There's been a bit of talk about this before. I found that I'm experiencing what's described in the first post of this issue: youshido-php/GraphQL#144 .

The schema is this:

type Query {
    Foo(uuid: String): String
}

I query my new endpoint like this:

query {
    Foo
}

Some process in graphql-tools, which I presume involves delegateToSchema, takes the received query and turns it into this:

query ($_uuid: String) {
    Foo(uuid: $_uuid)
}

--------
Variables:
{
    "_uuid": undefined
}

... Because JSON.stringify({a: undefined}) === '{}', the undefined variable definitions get thrown out, but the variable symbols stay in the query. Youshido\GraphQL then complains that it sees these variables, but no variable values to go along with them.

{"errors": [
    {"message": "Variable _uuid hasn't been submitted"}
]}

This is not a bug report, because I don't think it's clear if it's apollo/graphql-tools that need to be fixed, or Youshido\GraphQL. I personally think that if the variables are not included in the original query, they should not be in the forwarded one either. It all comes down to whether these four should be considered different or not:

query { Foo }
query { Foo(uuid: null) }
query ($_uuid: String) { Foo(uuid: $_uuid) } // variables: {}
query ($_uuid: String) { Foo(uuid: $_uuid) } // variables: {"_uuid": null}

Possibly related: #550

@freiksenet
Copy link
Contributor

This is fixed with new variable generation in #527. It's WIP, but it should land this month and this problem should be fixed then.

@hwillson
Copy link
Contributor

hwillson commented Sep 7, 2018

Fixed in #527 - thanks!

@hwillson hwillson closed this as completed Sep 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants