1

I have two entry types that I want to show in a sorted list (by postDate, with paginating).

{
  entries(
    type: ["entryType1", "entryType2"],
    orderBy: "postDate desc",
    limit: 5,
    offset: 0
  ) {
    id
    title
    postDate
    typeHandle
  }
}

This already works. Now the second post type entryType2 should have an optional Lightswitch showInList, where the editor can decide if the entry should appear in the list.

{
  entries(
    type: ["entryType1", "entryType2"],
    orderBy: "postDate desc",
    showInList: 1,
    limit: 5,
    offset: 0
  ) {
    id
    title
    postDate
    typeHandle
  }
}

Unfortunately with the adapted querying I only get the entries of the type with the Lightswitch field declared. When setting showInList: null I get all entries of both entry types, but its ignoring if showInList is true/false for any entry of the second post type. I tested different QueryArguments but its seems they all have no effect.

Every QueryArgument is handled as if true

Tested:

  • showInList: 1 → shows only entries of entryType2 with showInList set to true, ignores entryType2
  • showInList: ['not 1'] → I thought this would give all entries of entryType2 with showInList set to false but it behaves the same as showInList: 1
  • showInList: null → shows entries of both types but ignores the showInList field

is there something like showInList: ['1 or undefined'] or any other QueryArgument that would give me the expected result?

Tested in CraftCMS 3.4.17.1 with full schema

1 Answer 1

2

Just saw this resolved issue on GitHub: https://github.com/craftcms/cms/issues/5930

So Lightswitch querying should be fixed in the upcoming release CraftCMS 3.5


Edit: there is a workaround until 3.5 is released. see comment by @harrymee123 and my example query at https://github.com/craftcms/cms/issues/5930#issuecomment-657417173

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.