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

GraphQL: Cannot set draft on nested relations. Can set draft where draft is not enabled. #4985

Closed
dacgray opened this issue Feb 3, 2024 · 7 comments · Fixed by #6141
Closed
Assignees
Labels
status: needs-triage Possible bug which hasn't been reproduced yet

Comments

@dacgray
Copy link

dacgray commented Feb 3, 2024

Link to reproduction

No response

Describe the Bug

We have 2 collections.

TopFooterV1 - versioning with draft is NOT enabled.

StaticPageV1 - versioning with draft IS enabled.

1st Issue:

We cannot set a draft argument on the relation:

image
image

Would be very helpful if draft, where, locale, limit and sort are available.

2nd Issue:

The schema generator adds draft to a collection with versioning and drafts disabled:

  TopFooterV1s(draft: Boolean, where: TopFooterV1_where, fallbackLocale: FallbackLocaleInputType, locale: LocaleInputType, limit: Int, page: Int, sort: String): TopFooterV1s

To Reproduce

As above

Payload Version

2.9.0

Adapters and Plugins

"@payloadcms/bundler-webpack": "^1.0.6", "@payloadcms/db-mongodb": "^1.3.2", "@payloadcms/plugin-cloud-storage": "^1.1.1", "@payloadcms/plugin-sentry": "^0.0.6", "@payloadcms/richtext-slate": "^1.3.1",

@evelynhathaway
Copy link

I was running into this with an without GraphQL in #3963 (reply in thread).

In Payload v2.16.1, I no longer experience it with the REST API and if I manually add the draft variable to each relationship; however, I am not getting the cascading behavior noted in #6141.

@JarrodMFlesch
Copy link
Contributor

@evelynhathaway I just tested this and it seems to be working. Can you provide more context? Or possibly a small reproduction?

@evelynhathaway
Copy link

@JarrodMFlesch I think the difference is that I am using a global maybe?

With this repro: evelynhathaway@9bd24ff

And you open http://127.0.0.1:3000/api/graphql-playground and query:

{
  Menu(draft: true) {
    relationship {
      text
    }
  }
}

The output is published example post, but if the draft variable is set on the relationship, it will return the draft:

{
  Menu(draft: true) {
    relationship(draft: true) {
      text
    }
  }
}

@evelynhathaway
Copy link

I also ran into this with Rich Text links that are relationships. At least with the Slate editor and GraphQL, there isn't a draft variable, and will always return the published version (or the first draft if no published version exists).

This prevents rich text relationship links from working if the linked document location changed since the linked document was last published (or since the first draft if no published version exists)

@JarrodMFlesch would it be best to reopen this issue, or shall I create new issues to track these sub-issues?

@JarrodMFlesch
Copy link
Contributor

@evelynhathaway yes that would be super helpful actually!

@evelynhathaway
Copy link

Created #6642 and #6643 for the discussed sub-issues

Copy link

github-actions bot commented Sep 7, 2024

This issue has been automatically locked.
Please open a new issue if this issue persists with any additional detail.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: needs-triage Possible bug which hasn't been reproduced yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants