Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: 7.2.1 - GraphQL returning invalid URL for accessing content?
Hi all,
I'm exploring GraphQL in 7.2 GA2, using Altair as a chrome extension.
I'm currently able to find a content with this query:
But the URL provided by the query is failing with a 400 status and the following message is appearing on the log:
Is this a bug or am I doing something wrong?
TIA
Fernando
I'm exploring GraphQL in 7.2 GA2, using Altair as a chrome extension.
I'm currently able to find a content with this query:
query{
structuredContentByKey(key: "35506", siteId: 20124){
friendlyUrlPath
title
renderedContents{
renderedContentURL
templateName
}
}
}
The query result is:{
"data": {
"structuredContentByKey": {
"friendlyUrlPath": "directions-generic",
"title": "Directions - generic",
"renderedContents": [
{
"renderedContentURL": "http://localhost:8080/o/graphql/v1.0/structured-contents/35508/rendered-content/28105",
"templateName": "Basic Web Content"
},
{
"renderedContentURL": "http://localhost:8080/o/graphql/v1.0/structured-contents/35508/rendered-content/35566",
"templateName": "Alternative BWC template"
}
]
}
}
}
But the URL provided by the query is failing with a 400 status and the following message is appearing on the log:
[AbstractGraphQLHttpServlet:141] Bad GET request: path was not "/schema.json" or no query variable named "query" given
Is this a bug or am I doing something wrong?
TIA
Fernando
Good catch, that's a bug. I've created this ticket to track it: https://issues.liferay.com/browse/LPS-105982 Thanks!
As a temporal workaround, if you know the templateId, you can use renderedContentTemplate(templateId: X)
Thanks Javier, it works! :-)
The final query is:
Oddly, this query expects the article primary key instead of the articleId used in the other query. Any idea why?
Thanks
Fernando
The final query is:
query{
structuredContentRenderedContentTemplate(structuredContentId: 35508 , templateId: 35566 )
}
Oddly, this query expects the article primary key instead of the articleId used in the other query. Any idea why?
Thanks
Fernando
Hi Fernando, you could try:
query{
structuredContentByKey(key: "35506",siteKey: "yourSiteKey"){
renderedContentTemplate(templateId: 35566)
}
}
yourSiteKey would be same as group_.groupkey in db (which I think is always? the same as the site name)
query{
structuredContentByKey(key: "35506",siteKey: "yourSiteKey"){
renderedContentTemplate(templateId: 35566)
}
}
yourSiteKey would be same as group_.groupkey in db (which I think is always? the same as the site name)
Thanks Jack! Your suggested query also works:
query{
structuredContentByKey( key: "35506", siteKey: "Guest" ){
renderedContentTemplate(templateId: 35566)
}
}
I am leaning to using keys wherever I can, so that I can avoid looking in the database.
Yes, the idea in the future is to move away from ids (that typically only appear in the database) into keys and external reference codes and show those in the UI.
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™