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.

Relationship field returns null on production app API but not localhost

default discord avatar
nlvogel2 years ago
30

When I view my CMS on my machine, I see the full relationship:


{
"format": "",
"type": "relationship",
"version": 1,
"relationTo": "addresses",
"value": {
"id": "6508ec3945c357227a95e85c",
"locationName": "Mailing Address",
"streetAddress": "*****",
"city": "North Chesterfield",
"state": "VA",
"zip": "23235",
"createdAt": "2023-09-19T00:32:57.541Z",
"updatedAt": "2023-09-21T15:56:37.797Z",
"country": "",
"optionalAdditionalStreetAddress": "*****"
}
}


But when I view it in production, this is what I see:


                {
                  "format": "",
                  "type": "relationship",
                  "version": 1,
                  "relationTo": "addresses",
                  "value": null
                }


Am I missing a configuration to make the relationship return the correct value?



Here are my versions:


"dependencies": {
    "@aws-sdk/client-s3": "^3.468.0",
    "@aws-sdk/lib-storage": "^3.468.0",
    "@payloadcms/bundler-webpack": "^1.0.6",
    "@payloadcms/db-mongodb": "^1.4.1",
    "@payloadcms/plugin-cloud-storage": "^1.1.1",
    "@payloadcms/richtext-lexical": "^0.6.1",
    "@swc/core": "^1.3.92",
    "cross-env": "^7.0.3",
    "dotenv": "^8.2.0",
    "express": "^4.17.1",
    "nodemailer-sendgrid": "^1.0.3",
    "payload": "^2.11.0"
  },


Depth is the same level and other relationships populate correctly.



Actually, I lied - no relationship is working in production



The relationship shows up properly in my MongoDB, as well



Just bumping this up. Hoping to have someone take a look or help me with troubleshooting

  • default discord avatar
    notchr2 years ago

    Morning!



    So you're saying no relationships work in prod?

  • default discord avatar
    nlvogel2 years ago
    @1049775120559898725

    Correct! In local dev, I’m able to see the full relationship in my API section. When Payload is deployed and I’m in my actual prod CMS, the value is null.

  • default discord avatar
    notchr2 years ago

    Weirddd



    Payload version?

  • default discord avatar
    nlvogel2 years ago

    2.11.0

  • default discord avatar
    notchr2 years ago

    Postgres?



    oh mongo

  • default discord avatar
    nlvogel2 years ago

    If deployment matters, I provisioned Mongo from Railway

  • default discord avatar
    notchr2 years ago

    I'm not sure if it does, it's odd to me that your compiled collections are returning different information

  • default discord avatar
    nlvogel2 years ago

    It’s baffling to me. I see the id in my db but not in prod

  • default discord avatar
    notchr2 years ago

    can i see the field config in collection setup

  • default discord avatar
    nlvogel2 years ago

    I’ll need a few minutes before I can fire that up. If you’re looking for read access, though, that is set properly. I’m able to query the collection when it’s not a relationship in richtext (lexical)

  • default discord avatar
    notchr2 years ago

    just wanted to see how the relation is setup



    very odd



    I wonder if

    @858693520012476436

    knows anything about this

  • default discord avatar
    nlvogel2 years ago
    @1049775120559898725

    here's the collection:

    import {CollectionConfig} from 'payload/types';
    import {userPerms} from "../utilities/permissions";
    
    const Addresses: CollectionConfig = {
        slug: 'addresses',
        admin: {
            useAsTitle: 'locationName',
            group: 'Admin'
        },
        access: {
            read: () => true,
            create: userPerms,
            update: userPerms,
            delete: userPerms,
        },
        fields: [
            {
                name: 'locationName',
                type: 'text',
                required: true,
            },
            {
                name: 'streetAddress',
                type: 'text',
                required: true,
            },
            {
                name: 'optionalAdditionalStreetAddress',
                type: 'text',
            },
            {
                name: 'city',
                type: 'text',
                required: true,
            },
            {
                name: 'state',
                type: 'text',
                required: true,
            },
            {
                name: 'zip',
                type: 'text',
                required: true,
            },
            {
                name: 'country',
                type: 'text',
            },
            {
                name: 'meetingAddress',
                label: 'Is this the meeting address?',
                type: 'checkbox',
            },
        ],
    }
    
    export default Addresses;


    Lexical config:

    editor: lexicalEditor({
            features: ({defaultFeatures}) => [
                ...defaultFeatures,
                LinkFeature({}),
                RelationshipFeature({}), // added for troubleshooting
                SlateToLexicalFeature(),
                BlocksFeature({
                    blocks: [
                        CTAs, ContentWithMedia
                    ]
                })
            ]
        }),
  • default discord avatar
    notchr2 years ago

    wheres the relationship

  • default discord avatar
    nlvogel2 years ago

    In the Lexical config from the defaults. I can select the relationship



  • default discord avatar
    nlvogel2 years ago

    I'll check that in a second, but first a few more screenshots

  • default discord avatar
    notchr2 years ago

    does it need ` enabledCollections

  • default discord avatar
    nlvogel2 years ago

    local:

  • default discord avatar
    notchr2 years ago

    right



    @360823574644129795

    may have some insight too, he made this one

  • default discord avatar
    nlvogel2 years ago

    Prod:



    Sorry for the spam, I'll check the resource you sent!



    @1049775120559898725

    (and

    @360823574644129795

    and

    @858693520012476436

    since you all were mentioned above) - I tried

    enabledCollections

    in the

    RelationshipFeature

    and

    enableRichTextRelationship

    at the collection level - none of those worked. From the docs, all of those default to

    true

    anyway, which would be why I can select them in my Lexical editor and (in theory) should be able to query it in prod

  • default discord avatar
    ritsu04552 years ago

    could it be just access issue?

  • default discord avatar
    nlvogel2 years ago
    @423216344302092288

    Access is set to

    access: {read: () => true, // more code}

    and I'm able to query the collection outside of the relationship.

  • default discord avatar
    notchr2 years ago

    Can you



    Make a normal relationship, outside of lexical



    and see if that gets populated?



    We should narrow down if this is specific to relationships, or lexical relationship feature

  • default discord avatar
    nlvogel2 years ago

    yep! see attached.

  • default discord avatar
    notchr2 years ago

    and its not populated?



    Can we see the field configs

  • default discord avatar
    nlvogel2 years ago

    Oh sorry, that is populated. First screenshot is local, second is prod.


    {name: 'testAddressRelationship',
        type: 'relationship',
        relationTo: 'addresses',
    },


    i'm going to try querying on the front end in just a minute

  • discord user avatar
    alessiogr
    2 years ago

    I would try reproducing it in the latest 3.x beta release of lexical. There's been tons of changes related to population within lexical in 3.0, and we likely won't backport those fixes to 2.0



    There's a good chance this is fixed in 3.x

  • default discord avatar
    nlvogel2 years ago

    I'll give it a shot, thank you



    just to clarify - you do mean payload 3.x?

  • default discord avatar
    notchr2 years ago

    Yes they do

  • default discord avatar
    nlvogel2 years ago

    It appears that upgrading to 3.x solves this issue. I look forward to the stable version!

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.