-
Notifications
You must be signed in to change notification settings - Fork 202
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
Custom query input invalid value #3471
Comments
Thanks for opening the issue.. Our team will invetigate and provide and update. |
@evan1108 Can you enable verbose logging and provide the output logs when your attempting the request? To enable verbose logging, add the following statement as part of your app startup sequence when you're initializing Amplify:
Also, this code snippet seems to be imcomplete as the
|
Here are the verbose logs for when I pass in a JSON String to
|
@evan1108 This code snippet seems to be working for me from the client side: let data = try? JSONEncoder().encode(filter)
let jsonObject = try? JSONSerialization.jsonObject(with: data!, options: [])
return GraphQLRequest<[ProductData]>(
document: document,
variables: ["filter": jsonObject],
responseType: [ProductData].self,
decodePath: operationName
) The output log for variables is:
|
Thanks, @phantumcode, that works for me as well! It would be great to see the Advanced Workflows Amplify documentation include examples where the parameters of the query are an object, like I have here, instead of just a couple string fields. Same for including an example of a schema.graphql file where a custom query uses an Thank you for your response and help! |
Thanks @evan1108 for the feedback. I've submitted a PR to improve the documentation for the Advanced Workflow section for this use case. Closing this issue as you've been able to get your request working. |
|
Describe the bug
I'm trying to use an input type I defined in my scheam.graphql file,
productFilterInput
, as the input to a custom query that is using a lambda resolver. None of the values I use in the put for the query are valid and I continually get the error from GraphQL,"Amplify.GraphQLError(message: "Variable \'filter\' has an invalid value.", locations: Optional([Amplify.GraphQLError.Location(line: 1, column: 16)]), path: nil, extensions: nil)"
I'm able to pass a JSON query variable in the AppSync console and successfully execute my queries, e.g.
Here's the type and input I've defined in my schema.graphql file:
And here's my custom GraphQL Request:
And this is how I execute the request.
In the GraphQL extension, if I attempt to pass in the
filter
ProductInputFilter object directly, I get the error,"error APIError: Variables is a not a valid JSON object"
. If I try to serialize thefilter
object into a JSON String, I get the error I mentioned at the beginning,"Variable \'filter\' has an invalid value."
How am I supposed to pass an input type into my Swift GraphQL request? The documentation in the Amplify docs is not clear.
Steps To Reproduce
Expected behavior
A response is returned with the data from my DB (I'm using a custom lambda resolver that queries a PostgreSQL backend).
Amplify Framework Version
2.15.3
Amplify Categories
API
Dependency manager
Swift PM
Swift version
5.8
CLI version
12.8.2
Xcode version
15.0.1
Relevant log output
Is this a regression?
Yes
Regression additional context
No response
Platforms
No response
OS Version
16.4
Device
iPhone 13 Pro, iPhone 14 Pro
Specific to simulators
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: