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

S.documentList() with filter does not work with content releases #8761

Open
mariusGundersen opened this issue Feb 25, 2025 · 1 comment
Open

Comments

@mariusGundersen
Copy link
Contributor

Because of how the S.documentList() resolves the type of children (which is completely unique and difficult to replicate for custom lists, but that's another story), it does not work with content releases.

Given the following structure:

S.listItem()
        .title('Tester')
        .child(S.documentList().apiVersion('2025-02-19').title('Test').filter(`...some filter that finds multiple types...`)),

If you create a new document in a release and try to open it from this list it will fail with the following error:

Image

The problem is that the the createDocumentChildResolverForItem calls resolveTypeForDocument which only looks for a draft or published document, not documents in the current perspective. Therefore it does not find the document and therefore does not find the type and the above error is shown.

Which versions of Sanity are you using?

This is on version 3.77

@mariusGundersen
Copy link
Contributor Author

This might be besides the point, but as mentioned above this entire method seems a bit of a hack. It's weird that the child resolver isn't told what the type should be, when documentList knows what the type is, since it has a list of documents with both _id and _type. The intent for opening also contains the schemaType. So it seems very natural to pass down the type argument to the child resolver.

Another solution is to pass down the current perspective as part of the child resolver context. But that still requires it to figure out the type of something given the _id.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant