Like what we’re doing? Star us on GitHub!

GraphQL Error on Startup

alexdev
2 months ago
16

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

  • Exo
    2 months 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?

  • alexdev
    2 months 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

  • Exo
    2 months ago

    that makes sense, I had a similar setup. After switching to yarn you should be fine I think 🙂

  • alexdev
    2 months 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?

  • Exo
    2 months 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 🙂



    @jmikrut 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 😦

  • jmikrut
    Payload Team
    2 months ago

    ahhh is this related to

    express-graphql

    ?

  • Exo
    2 months ago

    Yes I think so 🙂



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

  • jmikrut
    Payload Team
    2 months 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

  • alexdev
    2 months ago

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

  • HSWMK
    3 weeks ago

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

Open the post
Continue the discussion in Discord
Can't find what you're looking for?
Get help straight from the Payload team with an Enterprise License.Learn More