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

Variables not being proxied #56

Closed
jcorbett-sweater opened this issue Mar 28, 2024 · 2 comments · Fixed by #59
Closed

Variables not being proxied #56

jcorbett-sweater opened this issue Mar 28, 2024 · 2 comments · Fixed by #59
Assignees
Labels
bug Something isn't working

Comments

@jcorbett-sweater
Copy link

When I try to use the proxy with a request with variables, the variables aren't forwarded to the graphql server. Here is my code:

proxy_schema = ProxySchema()

proxy_schema.add_remote_schema("http://localhost:8080/graphql/")
final_schema = proxy_schema.get_final_schema()

app = GraphQL(
    final_schema,
    context_value=get_context_value,
    root_value=proxy_schema.root_resolver,
    debug=True,
)

My request:

{"query":" mutation($email:String!,$password:String!) {
	signIn(input:{email:$email,password:$password}) {
		tokens {
			idToken
			accessToken
			refreshToken
		}
	  userErrors {
			__typename
			... on ErrorBase {
				message
			}
		}
	}
}","variables":{"email":"[email protected]","password":"some-password"}}

What the graphql server receives:

{
    "operationName": null,
    "query": "mutation {
  signIn(input: {email: $email, password: $password}) {
    tokens {
      idToken
      accessToken
      refreshToken
    }
    userErrors {
      ... on ErrorBase {
        message
      }
    }
  }
}",
    "variables": {}
  }
@rafalp rafalp added the bug Something isn't working label Mar 29, 2024
@rafalp
Copy link
Contributor

rafalp commented Mar 29, 2024

We have quite a few tests for variable handling and all of them are passing currently. I am wondering if issue here is an anonymous operation?

@jcorbett-sweater
Copy link
Author

I am not very familiar with the codebase, but in query_filter.py line 69 (method get_schema_query_with_used_variables) you initialize a QueryFilterContext. However nothing ever sets the variables in that context. I hacked something that is working, but I'm sure it's not right. After line 79 I added:

                for variable in operation_node.variable_definitions:
                    context.variables.add(variable.variable.name.value)

That fixes my error, but like I said I doubt that's the right place. Also I haven't tested extensively to make sure it doesn't break other things. I'll have a look at your tests to understand what's different about my case. I tried naming the operation, but it didn't seem to make a difference. I'll post more info as I find it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants