Hi all,
I’m hoping you can help me with an issue related to the variable used in a GraphQL request.
I loaded the GraphQL schema using introspection and created a variable for the collection to run tests. However, the variable is showing a null value in the query, which leads to a validation error: “Variable ‘propertyUid’ has coerced Null value for NonNull type ‘String!’”.
Any insights on what might be causing this or how to resolve it would be greatly appreciated!
2 Likes
Hey
Welcome to the Postman Community!
One question, have you saved the Collection variable? I can see from the image that it has unsaved changes in there.
If you enable autosave, from the General Settings - Does this help?
Hi Danny, I have saved the variable as well as enabled autosave, but the validation error pesists, any suggestions?
Does it work as expected when you hardcode a value into the variable?
The example this use in their documentation is slightly different from yours:
query {
property(uid: "${propertyUid}") {
uid
agencyUid
name
isActive
pictureLink
webLink
bedrooms
beds
bathrooms
numberOfFloors
rentalLicenseNumber
rentalLicenseExpirationDate
}
}
I’d be lying if I said I know a ton about GraphQL to be honest
Hi Danny, if I dont use the variable and add the value of the propertyUid directly in the query, it works, so I am having issue with how the variable is used in Postman
Sorry, I meant if you hardcode that in the variable section itself (replacing the postman variable syntax).
Is it what you means? I still get the same error
Hmm…
I’m not sure what’s happening there from that API - using our echo service I’m able to use a Collection level variable as a GraphQL Variable, which is resolved in the query
Hello ,
I tried it too, I am unable to reproduce the error, but I created a public collection, in case you want to make changes to it or compare it with the API you have - GraphQL request using variables
Also, I see in this screenshot that the Property object has two uids - one with String! and the other with String, that seems confusing, I’m not sure if that’s probably an issue. Could you try using the variable for another field? like say “name” and see if the problem still persists?
1 Like
I think that’s probably the issue from API provider, I will contact them for further insight. Thanks for your help
Thanks for your help Danny. I think that’s probably the issue from API provider, I will contact them for further insight.
1 Like
For future debugging purposes, I always look at the requests that were sent in the console. That way I can see what my variables are resolving to. The console shows all the sent requests along with the request/response bodies and headers. This would be worth checking out if you don’t hear from the API maintainer.
Another thing to check is if the property id you’re using exists in the system, it could just be an unfriendly “not found” error response