Error using payload generate graphQLSchema

default discord avatar
\ ឵឵឵
7 months ago
39

Recently, started getting this error when trying to run

payload generate:graphQLSchema

:



payload/node_modules/graphql/utilities/printSchema.js:54
  const directives = schema.getDirectives().filter(directiveFilter);
                            ^

TypeError: Cannot read properties of undefined (reading 'getDirectives')


The full command I'm using is

dotenv payload generate:graphQLSchema

, and

PAYLOAD_CONFIG_PATH

is defined in .env, though I have also tried running it with

-v PAYLOAD_CONFIG_PATH=src/payload.config.ts

just to be sure.



I have generated the GraphQL schema successfully recently, so wondering if this looks familiar to anyone.

  • default discord avatar
    \ ឵឵឵
    7 months ago

    @denolfe Thanks!

  • default discord avatar
    generator101
    7 months ago

    @denolfe I am getting a different error



    const err = new MongooseError(message);


    ^



    MongooseError: Operation

    users.countDocuments()

    buffering timed out after 10000ms



    I updated to version 1.6.12

  • discord user avatar
    denolfe
    Payload Team
    7 months ago

    That typically indicates a connectivity issue to your mongo server



    or a permissions issue

  • default discord avatar
    ssyberg
    3 months ago

    @denolfe what kind of permissions issue? I can spin up just fine with

    yarn dev

    (so mongo is running and payload can connect) but I'm also getting this connection timeout, first time trying to generate schema

  • discord user avatar
    denolfe
    Payload Team
    3 months ago

    Interesting, so the app works fine normally. You

    only

    get this when generating schema?

  • default discord avatar
    ssyberg
    3 months ago

    Correct

  • discord user avatar
    denolfe
    Payload Team
    3 months ago

    Definitely odd, Payload version?

  • default discord avatar
    ssyberg
    3 months ago

    1.8.2



    I've made some changes to my server.ts, not sure if that could be related

  • discord user avatar
    denolfe
    Payload Team
    3 months ago

    No, that shouldn't be an issue



    Can you paste the script you're running to generate types from your package.json?



    Should be something like

    "generate:graphQLSchema": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts payload generate:graphQLSchema"
  • default discord avatar
    ssyberg
    3 months ago
    "generate:graphQLSchema": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.js payload generate:graphQLSchema",


    and for reference



    "dev": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.js nodemon",


    (not using typescript, not sure if that could be related as well)



    One other data point, I'm overriding the routes as follows:


        routes: {
            admin: '/cms/admin',
            api: '/cms/api',
            graphQL: '/cms/graphql',
            graphQLPlayground: '/cms/graphiql',
        },


    and this 404s:

    http://localhost:3000/cms/graphql


    maybe thats expected though since there's no query?



    This also 404s:

    http://localhost:3000/cms/graphiql
  • discord user avatar
    denolfe
    Payload Team
    3 months ago

    There could be something going on there, since I think

    graphQLPlayground

    builds upon

    api

    . Here are the defaults:


      routes: {
        admin: '/admin',
        api: '/api',
        graphQL: '/graphql',
        graphQLPlayground: '/graphql-playground',
      },


    I don't believe the JS would be an issue since this just executes a JS script that we ship with the package



    Maybe remove the routes temporarily and see if it runs differently



    The way you have your routes would actually make graphQLPlayground URL be

    /cms/api/cms/graphiql

    or something like that

  • default discord avatar
    ssyberg
    3 months ago

    AH didn't realize it was building off of api



    Alright playground is working at least



    So it looks like it's actually running some queries on the data, if there was a bug in my config that passed validation, but was otherwise breaking the API, would that explain it? It's certainly possible I have some broken hook or infinite loop somewhere that I haven't stumbled on (though I kinda assumed this would be generated from static config data)



    MongooseError: Operation

    centers.countDocuments()

    buffering timed out after 10000ms


    So I've implemented a little shell and I just tried running that query directly on the centers model and its returning 6 (which is correct)



    I spun up a new payload app and generate schema is working just fine, so it's gotta be something specific to my config



    Seems like that is only called within

    auth

    ?

    https://github.com/search?q=repo%3Apayloadcms%2Fpayload+countDocuments&type=code


    well not sure whats going on, but I just rewrote the script and called it from my custom management command runner and it worked...

    image.png
  • discord user avatar
    jmikrut
    Payload Team
    3 months ago

    a code gremlin

  • default discord avatar
    Matze
    3 months ago

    I tried using a local version of payload with one scss change via

    yarn link

    but got also the error

    MongooseError: Operation admins.countDocuments() buffering timed out after 10000ms

    (admins is my admin collection). Is this related or excepted with

    yarn link

    ?

  • discord user avatar
    denolfe
    Payload Team
    3 months ago

    I would not expect linking to cause an issue, we use it at times during development.

Open the post
Continue the discussion in Discord
Like what we're doing?
Star us on GitHub!

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.