Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Can't query relationship in Block

default discord avatar
itsjxck2 years ago
4

We're trying to use blocks to apply filter config to collection items.



I have a block defined like so:


const CategoryFilterBlock: Block = {
  slug: "CategoryFilter",
  fields: [
    {
      name: "categoryFilterType",
      label: "Type",
      type: "radio",
      options: ["whitelist", "blacklist"],
      defaultValue: "whitelist",
    },
    {
      name: "categories",
      type: "relationship",
      relationTo: Categories.slug,
      hasMany: true,
    },
  ],
};


Which is used on the collection like so:


{
  <collection_config>,
  {
    name: "filters",
    type: "blocks",
    blocks: [CategoryFilterBlock],
  }
}


I can query the

blockType

field and the

categoryFilterType

field, but I can't query for a value in the relationship:


// Works
{
  "filters.blockType": {
    equals: "CategoryFilter"
  }
}

// Also works
{
  "filters.categoryFilterType": {
    equals: "whitelist"
  }
}

// Doesnt work
{
  "filters.categories.label": {
    equals: "Some category label"
  }
}


Is this a bug or is this just outright not possible?

  • default discord avatar
    Mark | Omniux2 years ago

    Currently not possible I think. Extending the GraphQL capabilities of the API is a planned part of the roadmap

  • default discord avatar
    itsjxck2 years ago

    Should have mentioned this is with REST queries not GraphQL

  • discord user avatar
    jesschow
    2 years ago

    Hey @itsjxck are you still looking for help here?

  • default discord avatar
    itsjxck2 years ago

    I don't know if this is still an issue or not as we parked the changes in favour of other work. I will retry and report back, but my assumption would be that it is probably fixed now

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.