Skip to content
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

Component Relation Publication State needs to be set at each level #917

Open
kasonde opened this issue May 23, 2022 · 6 comments
Open

Component Relation Publication State needs to be set at each level #917

kasonde opened this issue May 23, 2022 · 6 comments
Assignees
Labels
issue: docs/instructions Issues about incorrect instructions found on docs.strapi.io target: v4 Documentation PRs/issues targeting content from docs.strapi.io (main branch).

Comments

@kasonde
Copy link
Contributor

kasonde commented May 23, 2022

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

  1. 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

image

@kasonde kasonde added issue: bug severity: high If it breaks the basic use of the product status: confirmed Confirmed by a Strapi Team member or multiple community members labels May 23, 2022
@Convly
Copy link
Member

Convly commented May 30, 2022

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.

@derrickmehaffy
Copy link
Member

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.

@Convly
Copy link
Member

Convly commented May 30, 2022

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 🤷‍♂️

Sorry for the undocumented change, it must've been lost among all the other things 🙏

@derrickmehaffy derrickmehaffy removed issue: bug severity: high If it breaks the basic use of the product status: confirmed Confirmed by a Strapi Team member or multiple community members labels May 31, 2022
@derrickmehaffy
Copy link
Member

No problem, I'll transfer this over to the documentation repo to have it added into the docs.

@derrickmehaffy derrickmehaffy changed the title Component Relation Publication State isn't respected in GraphQL Component Relation Publication State needs to be set at each level May 31, 2022
@derrickmehaffy derrickmehaffy transferred this issue from strapi/strapi May 31, 2022
@ghost
Copy link

ghost commented Jun 2, 2022

  • 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

@pwizla pwizla added the target: v4 Documentation PRs/issues targeting content from docs.strapi.io (main branch). label Jun 15, 2022
@pwizla pwizla self-assigned this Sep 19, 2022
@galago
Copy link

galago commented Feb 2, 2023

It's been over a year and this issue is still a big problem and unsolved. Please fix it in future releases.

@pwizla pwizla added the issue: docs/instructions Issues about incorrect instructions found on docs.strapi.io label Oct 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue: docs/instructions Issues about incorrect instructions found on docs.strapi.io target: v4 Documentation PRs/issues targeting content from docs.strapi.io (main branch).
Projects
None yet
Development

No branches or pull requests

5 participants