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.

Graphql Update Fails TypeError: Cannot read properties of null (reading '_id')

default discord avatar
andr_ec2 years ago
3

any simple graphql update fails with this error



[16:50:45] ERROR (payload): TypeError: Cannot read properties of null (reading '_id')
    at getLatestCollectionVersion (/home/andre/Documents/qreate-server/qreate-payload/node_modules/payload/src/versions/getLatestCollectionVersion.ts:36:18)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at updateByID (/home/andre/Documents/qreate-server/qreate-payload/node_modules/payload/src/collections/operations/updateByID.ts:111:15)
    at resolver (/home/andre/Documents/qreate-server/qreate-payload/node_modules/payload/src/collections/graphql/resolvers/update.ts:38:20)
    at handler (/home/andre/Documents/qreate-server/qreate-payload/node_modules/graphql-http/lib/handler.js:283:22)
    at requestListener (/home/andre/Documents/qreate-server/qreate-payload/node_modules/graphql-http/lib/use/express.js:27:34)


payload version:


    "payload": "^1.9.5",


graphql query:


mutation UpdatePath($id: String!, $input: mutationPathUpdateInput!) {
  updatePath(id: $id, data: $input) {
    id
  }
}


variables:


{
  "id": "6491d674bedd83aa362d8585",
  "input": {
    "title": "updated"
  }
}


Collection config:


const Paths: CollectionConfig = {
  slug: "paths",
  versions: false,
  access: {
    read: (req) => {
      return true
    },
    create: (req) => {
      return true;
    },
  },
  fields: [
    {
      name: "title",
      label: "Title",
      type: "text",
    },
  ],
};


I can create an issue in github if needed.

  • discord user avatar
    dribbens
    2 years ago

    Hey

    @777074739372883968

    I think it would be helpful if you made an issue as you said.


    What happens if you remove

    versions: false

    from your collection config?



    It seems that Payload's version logic might be trying to do something somewhere with

    versions

    even though you're intentionally not using it. Leaving it undefined may just bypass this little bug if it is in fact the problem.

  • default discord avatar
    andr_ec2 years ago

    Removing versions still has the same problem. I actually added that to try to debug.

    @969226489549713438

    yeah I’ll create an issue in GitHub



    I found the problem. I was passing in the wrong id. maybe there's a better error to show in the console?

  • discord user avatar
    dribbens
    2 years ago

    Yeah, that error should be different for sure.



    Thanks for reporting the issue!

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.