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.

Error using payload generate graphQLSchema

default discord avatar
bcksl2 years ago
16

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
    bcksl2 years ago
    @967118574445547650

    Thanks!

  • default discord avatar
    generator1012 years ago
    @967118574445547650

    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
    2 years ago

    That typically indicates a connectivity issue to your mongo server



    or a permissions issue

  • default discord avatar
    ssyberglast year
    @967118574445547650

    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
    last year

    Interesting, so the app works fine normally. You

    only

    get this when generating schema?

  • default discord avatar
    ssyberglast year

    Correct

  • discord user avatar
    denolfe
    last year

    Definitely odd, Payload version?

  • default discord avatar
    ssyberglast year

    1.8.2



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

  • discord user avatar
    denolfe
    last year

    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
    ssyberglast year
    "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
    last year

    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
    ssyberglast year

    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...

  • discord user avatar
    jmikrut
    last year

    a code gremlin

  • default discord avatar
    roydigerhundlast year

    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
    last year

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

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.