documentation
documentation copied to clipboard
Component Relation Publication State needs to be set at each level
Bug report
Required System information
- Node.js version: 14
- NPM version: 6
- Strapi version: 4.1.9
- Database: SQLite
- Operating system: MacOS Mojave
Describe the bug
Publication State isn't applied in component fields when making a graphql query.
Steps to reproduce the behavior
- Create Content Strucure as below: alloys
{
"kind": "collectionType",
"collectionName": "alloys",
"info": {
"singularName": "alloy",
"pluralName": "alloys",
"displayName": "alloy"
},
"options": {
"draftAndPublish": true
},
"pluginOptions": {},
"attributes": {
"name": {
"type": "string"
},
"tp_with_st": {
"displayName": "tp_with_st",
"type": "component",
"repeatable": true,
"component": "shared.tp-with-st"
}
}
}
st
{
"kind": "collectionType",
"collectionName": "sts",
"info": {
"singularName": "st",
"pluralName": "sts",
"displayName": "st"
},
"options": {
"draftAndPublish": true
},
"pluginOptions": {},
"attributes": {
"name": {
"type": "string"
}
}
}
tp
{
"kind": "collectionType",
"collectionName": "tps",
"info": {
"singularName": "tp",
"pluralName": "tps",
"displayName": "tp"
},
"options": {
"draftAndPublish": true
},
"pluginOptions": {},
"attributes": {
"name": {
"type": "string"
}
}
}
tp_with_st
{
"collectionName": "components_shared_tp_with_sts",
"info": {
"displayName": "tp_with_st",
"icon": "adjust",
"description": ""
},
"options": {},
"attributes": {
"st": {
"type": "relation",
"relation": "oneToOne",
"target": "api::st.st"
},
"tp": {
"type": "relation",
"relation": "oneToOne",
"target": "api::tp.tp"
}
}
}
Make a GraphQL query, querying alloys and notice that the publication state of the one-to-one related elements on the component is not respected.
Expected behavior
For all element publication state to be respected.
Screenshots

Hey, is the issue the fact that you've to add a publicationState: LIVE
to the relation attributes too?
If it's that, then it's the wanted behavior as we don't cascade this state to child resolvers.
Hey, is the issue the fact that you've to add a
publicationState: LIVE
to the relation attributes too? If it's that, then it's the wanted behavior as we don't cascade this state to child resolvers.
Ah this is one of the undocumented changes from v3 where it ran globally.
Indeed. In V3 we were sharing the state to child resolvers but it didn't really make sense in a GraphQL architecture where every resolver should be as isolated as possible. However, I do agree that from a product perspective it's a bit awkward to redefine this state for every relation, especially for content types where you have a lot of them. One solution could be to write a custom resolver :man_shrugging:
Sorry for the undocumented change, it must've been lost among all the other things :pray:
No problem, I'll transfer this over to the documentation repo to have it added into the docs.
- The st and tp here are components
- tp_with_st is another component
- "alloys" is a collection with tp_with_st as a repeatable component
- Even if publication state is passed as live, draft st and tp show up in the results for alloys
It's been over a year and this issue is still a big problem and unsolved. Please fix it in future releases.