Skip to content

Invalid reference token when I use blockReferences in collection #59

@pafnuty

Description

@pafnuty

I started this issue so that there would be a context for the improvements that I prepared :)

The plugin does not process blocks if they are specified in the payload config and are used as blockReferences in the collection

Step to reproduce:

  1. Create block config:
import type { Block } from 'payload'

export const ReferenceBlock: Block = {
  slug: 'ReferenceBlock',
  fields: [
    {
      name: 'title',
      type: 'text',
      required: true,
    },
  ],
}
  1. Add blocks section with new block to payload.config.ts
export default buildConfig({
  // ...
  blocks: [ReferenceBlock],
  // ...
})
  1. Add to collection:
    {
      name: 'contentRef',
      type: 'blocks',
      blocks: [],
      blockReferences: ['ReferenceBlock'],
    }

Expected result:

I see ReferenceBlock in openapi docs

Actual result

Error with text:
Invalid reference token: ReferenceBlock

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions