payloadcms / payload

Payload is the open-source, fullstack Next.js framework, giving you instant backend superpowers. Get a full TypeScript backend and admin panel instantly. Use Payload as a headless CMS or for building powerful applications.
https://payloadcms.com
MIT License
25.69k stars 1.63k forks source link

plugin-form-builder: label localization not working when querying with GraphQL #5290

Open inuue opened 8 months ago

inuue commented 8 months ago

Link to reproduction

No response

Describe the Bug

Data in mongodb is ok and everything in payload admin works fine.

{
  "_id": {
    "$oid": "654a493a045c9d8adef71582"
  },
  "title": "Formularz kontaktowy",
  "fields": [
    {
      "name": "email",
      "label": {
        "pl": "PL lable",
        "en": "ENglish label"
      },
      "width": 100,
      "required": true,
      "autoComplete": "email",
      "validationMessage": {
        "pl": "Proszę podać poprawny adres email",
        "en": "English message validation"
      },
      "id": "65ee720228d57582945e6705",
      "blockName": "Email",
      "blockType": "email"
    },

  ]

}

GraphQL example that should retrieve information about 'start' page with pl locale: It's returning only en values from database only for form. All other blocks form layout that are localized work as expected and everything is fine:

query Page {
    Pages(where: { slug: { equals: "start" }}, locale: pl, fallbackLocale: pl, limit: 1) {
      docs {
        id
        title
        hero {
          type
          richText
        }
        layout {
          ...on FormBlock {
              blockName
              blockType
              enableIntro
              form {
                id
              title
              submitButtonLabel
              confirmationType
              confirmationMessage
              redirect {
                url
              }
              emails {
                emailTo
                emailFrom
                cc
                bcc
                replyTo
                subject
            }
            fields {
              ...on Email {
                blockType
                blockName
                width
                name
                label
                autoComplete
                validationMessage
                required
              }
              }

            }
            introContent
          }
        }
      }
    }
  }

To Reproduce

Use template from payload + next.js. Add form builder plugin create form and user graphql preview to query with provided sample

Payload Version

^2.11.1

Adapters and Plugins

db-mongodb, bundler-webpack, plugin-form-builder

inuue commented 7 months ago

Went down the path of version reverting to see where it breaks. It works fine with @2.5.0 it's not working @2.6.0.

I am new to the codebase so haven't tried making any changes yet. I want to deep-dive into commits listed below. I tried setting fallback locale to different languages but it ends up on "en" regardless.

https://github.com/payloadcms/payload/commit/9fac2ef24e2ade4cf55b0d6a0e7f67e0edf57539 https://github.com/payloadcms/payload/commit/98890eee1f527c8f245b2353d7e1caca4d2a7d8c