I have a graphql query which takes IDFilter! as parameter and this works fine in the graphql editor and when i try to request from postman i am getting
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Hi @IndrajithPa ,
Here are a few points you can check:
Variable Naming: Ensure the variable name in your GraphQL query (e.g., $expression) matches exactly with the name used in your Postman variables object.
JSON Structure: The request body in Postman should follow the correct format, including both "query" and "variables" keys, with properly structured JSON.
Headers: Make sure the Content-Type header is set to application/json.
Debugging Tip: If the query works in the AEM GraphQL editor but fails in Postman, it’s most likely due to incorrect payload formatting or mismatched variable names.
Regards,
Lavish Vasuja
@narendragandhi@Rohan_Garg@abhishekanand_@Dipti_Chauhan@Mahedi_Sabuj@pulkitvashisth@pulkitvashisth@RahulMohan@anasustic@muskaanchandwani
Kindly take a moment to review this question and share your valuable insights. Your expertise would be greatly appreciated!
Hi @IndrajithPa ,
The error you’re facing:
Variable 'expression' has coerced Null value for NonNull type 'IDFilter!'
means that the shape of your expression variable doesn’t match what the IDFilter! type expects. This is very common when calling GraphQL from Postman or other HTTP clients outside the AEM GraphiQL UI.
Based on your query and error, here’s the corrected format you should use for your GraphQL Variables in Postman: GraphQL Query
query ($expression: IDFilter!) {
internetList(filter: {
_path: $expression
}) {
items {
_path
}
}
}
Or, if you're trying to apply multiple OR filters, then that likely uses a LogicalExpression wrapper. But only if the schema supports it!
What You Must Check
Open your AEM GraphQL schema in the GraphiQL tool.
Check if the input for _path uses:
IDFilter! (single object), or
LogicalExpression! (for _logOp and _expressions).
If Schema Supports OR Filter with LogicalExpression
Then your query must change to:
Query:
query ($expression: LogicalExpression!) {
internetList(filter: {
_path: $expression
}) {
items {
_path
}
}
}
Variables:
{
"expression": {
"_logOp": "OR",
"_expressions": [
{
"_operator": "EQUALS",
"value": "/content/dam/sample/content-fragments/internet/internet1"
},
{
"_operator": "EQUALS",
"value": "/content/dam/sample/content-fragments/internet/internet2"
}
]
}
}
Note: Use LogicalExpression! as the variable type if _logOp is being used. IDFilter! cannot accept a LogicalExpression structure — that’s why you're getting the coercion error.
Regards,
Amit
Views
Replies
Total Likes
Hi @IndrajithPa ,
Here are a few points you can check:
Variable Naming: Ensure the variable name in your GraphQL query (e.g., $expression) matches exactly with the name used in your Postman variables object.
JSON Structure: The request body in Postman should follow the correct format, including both "query" and "variables" keys, with properly structured JSON.
Headers: Make sure the Content-Type header is set to application/json.
Debugging Tip: If the query works in the AEM GraphQL editor but fails in Postman, it’s most likely due to incorrect payload formatting or mismatched variable names.
Regards,
Lavish Vasuja
Views
Likes
Replies