Error: Schema must contain uniquely named types but contains multiple types named "Media".

default discord avatar
taun2160
3 months ago
11
 F:\git\TaunDevs\payload\node_modules\graphql\type\schema.js:219
        throw new Error(
              ^
Error: Schema must contain uniquely named types but contains multiple types named "Media".
    at new GraphQLSchema (F:\git\TaunDevs\payload\node_modules\graphql\type\schema.js:219:15)
    at registerSchema (F:\git\TaunDevs\payload\node_modules\payload\src\graphql\registerSchema.ts:77:20)
    at BasePayload.init (F:\git\TaunDevs\payload\node_modules\payload\src\payload.ts:210:21)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at getPayload (F:\git\TaunDevs\payload\node_modules\payload\src\payload.ts:431:22)
    at initHTTP (F:\git\TaunDevs\payload\node_modules\payload\src\initHTTP.ts:25:19)
    at Payload.init (F:\git\TaunDevs\payload\node_modules\payload\src\index.ts:12:21)
[nodemon] app crashed - waiting for file changes before starting...


payload-types.ts


 


Should I be deleting a string of code within the payload-types.ts file? How does that file get modified? I didn't make any changes to it.



Found the file, though I haven't a clue what to do.



Or I'm not understanding the clue.



Anyone have an idea? @notchr ?

  • default discord avatar
    notchr
    2 months ago

    Lets see



    @taun2160 Try to regenerate your types first



    check the package.json, I think the command is

    generate:types


    you can also regenerate the graphqlschema via

    generate:graphQLSchema


    npm run generate:types

    (or yarn)



    Your app may be stuck in a state where you have two conflicting defs



    That's my first guess, let me know if that works

  • discord user avatar
    jmikrut
    Payload Team
    2 months ago

    so this is because you have two "things" called Media



    it could be a block and a collection

  • default discord avatar
    notchr
    2 months ago

    That was my second guess haha

  • discord user avatar
    jmikrut
    Payload Team
    2 months ago

    like, if you have a block with the slug of

    media

    and a collection with slug

    media

    , that will be a conflict

  • default discord avatar
    notchr
    2 months ago

    But I figured it would have complained prior to them reaching this error

  • discord user avatar
    jmikrut
    Payload Team
    2 months ago

    yeah, is this new? or a result of something you added?

  • default discord avatar
    taun2160
    2 months ago

    I see, thanks guys



    I'm hacking together a mix of custom-website-series and payload-website, so this makes sense 😛

  • default discord avatar
    notchr
    2 months ago

    Happens to the best of us, let us know if you're able to solve it



    also @jmikrut not to hijack the thread, but in core-dev i posted a question regarding default save behavior on fields because i encountered an oddity

  • discord user avatar
    jmikrut
    Payload Team
    2 months ago

    ok ill check that out right now

  • default discord avatar
    notchr
    2 months ago

    Thanks man! No rush btw, I'm close to wrapping up for the day

  • default discord avatar
    artmelkon
    last month

    Hello, I'm having the same error: unhandledRejection Error: Schema must contain uniquely named types but contains multiple types named "Media". I copied the code from the GitHub repo "custom-website-series" and the slug media could be found twice One is in the collections/Media and the second one is in blocks/Media. When I change the slug in the blocks/Media to let us say I change the slug and types to "image" and regenerate payload-types and start the server I wouldn't get any error message but the browser wouldn't be able to load anything.

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.