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 Error on Startup

default discord avatar
Deleted User2 years ago
11

My docker container gives me the following logs on startup:



[17:05:31] INFO (payload): Starting Payload...
/home/node/app/node_modules/payload/node_modules/graphql/jsutils/devAssert.js:12
    throw new Error(message);
    ^

Error: Expected DateTime to be a GraphQL nullable type.
    at devAssert (/home/node/app/node_modules/payload/node_modules/graphql/jsutils/devAssert.js:12:11)
    at new GraphQLNonNull (/home/node/app/node_modules/payload/node_modules/graphql/type/definition.js:395:32)
    at /home/node/app/node_modules/payload/dist/collections/graphql/init.js:101:23
    at Array.forEach (<anonymous>)
    at initCollectionsGraphQL (/home/node/app/node_modules/payload/dist/collections/graphql/init.js:60:38)
    at registerSchema (/home/node/app/node_modules/payload/dist/graphql/registerSchema.js:58:24)
    at init (/home/node/app/node_modules/payload/dist/init.js:79:38)
    at initSync (/home/node/app/node_modules/payload/dist/init.js:143:22)
    at Payload.init (/home/node/app/node_modules/payload/dist/index.js:154:29)
    at Object.<anonymous> (/home/node/app/dist/server.js:15:19)



My docker compose file looks like this (some parts redacted):


payload:
    image: node:18-alpine
    ports:
      - '3001:3001'
    volumes:
      - ./payload:/home/node/app
    working_dir: /home/node/app/
    command: sh -c "npm run serve"
    depends_on:
      - mongo
    environment:
      MONGODB_URI: mongodb://mongo:27017/payload
      PORT: 3001
      PAYLOAD_SECRET: TESTING
    networks:
      - main

  mongo:
    image: mongo:latest
    ports:
      - '27017:27017'
    command:
      - --storageEngine=wiredTiger
    volumes:
      - data:/data/db
    logging:
      driver: none
    networks:
      - main


and the

./payload

directory I mount to my docker container contains a payload project I have already run

npm run build

on

  • default discord avatar
    exo37182 years ago

    It seems the npm based installation workflow is broken.



    Can you try deleting your

    node_modules

    folder and

    package-lock.json

    . Then run

    yarn install

    and check again?

  • default discord avatar
    Deleted User2 years ago

    this is plausible, I am using npm



    I am currently building in an ubuntu worker and then transferring the whole directory over to the host, including node_modules into the ./payload directory mentioned above

  • default discord avatar
    exo37182 years ago

    that makes sense, I had a similar setup. After switching to yarn you should be fine I think ๐Ÿ™‚

  • default discord avatar
    Deleted User2 years ago

    so rework the whole workflow to use yarn?



    i'll give it a go now



    switched to yarn, deploys perfectly!



    although this is now the only component of the project that utilises yarn over npm, not world ending but I wonder what is cauting the issue?

  • default discord avatar
    exo37182 years ago

    The problem seems that there are 2 different versions of the GraphQL engine being used (one directly and another as a dependency). With yarn this is no problem, as you can write rules for how to handle that (overrides.json) but npm is a bit more strict.


    Same for me, usually it is npm everywhere, once the dependencies are fixed we can switch back ๐Ÿ™‚



    oh btw, if everything works, please close this thread unless you need more help, this helps to keep things organized ๐Ÿ™‚



    @364124941832159242

    another occurrence of this bug, I think I commented yesterday on a related github issue (which I can't find right now) but the npm workflow is quite broken as of now ๐Ÿ˜ฆ

  • discord user avatar
    jmikrut
    2 years ago

    ahhh is this related to

    express-graphql

    ?

  • default discord avatar
    exo37182 years ago

    Yes I think so ๐Ÿ™‚



    should be reproducable with the minimal setup, but I did not try yet

  • discord user avatar
    jmikrut
    2 years ago

    ok i'll put this on the radar. I hear that

    express-graphql

    is no longer supported so it's probably just that we need to move to a package that uses our graphql version

  • default discord avatar
    Deleted User2 years ago

    Thanks for all the help guys, will close the thread now

  • default discord avatar
    hswmk2 years ago

    still got the problem, using pnpm on railway, working on local

  • default discord avatar
    mateuszwoskowicz2 years ago

    got the same problem, installing packages using yard helped

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.