pothos: Duplicate field / Duplicate typename - With Vite/SvelteKit

Hey

Im running into issues with vite/sveltekit when i save a resolver file, i think because of some module caching in vite, idk the exact reason. I managed to work around the Error: Duplicate typename: Another type with name LoginInput already exists. by

if (import.meta.env.DEV) {
   builder.configStore.typeConfigs.clear();
}

But then the next error was Error: Duplicate field definition for field email in LoginInput.

I don’t know if maybe exposing a way to clear the configStore would be enough.

I can’t really use giraphql without restarting the dev server which is not very productive.

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Comments: 16 (9 by maintainers)

Most upvoted comments

@pixelmund looked into this a bit. I don’t see a good way that is reliably safe to just clear the cache. There is another (relatively simple) work around that should work.

I don’t know exactly how you structured your graphql/giraphql code, but if you dynamically import your schema into the file that defines your builder everything should just work.

I set up tiny example to test this out here: https://github.com/hayes/svelekit-graphql-test/tree/main/src/graphql

I haven’t done any thorough testing, but I am fairly confident this should work reliably. Let me know if this works, or if you have any issues!

Sorry, small oversight on my part on how the release script works. Should be fixed now

No problem, thank you very much!

I tested it and at first it still throw me the SchemaBuilder is not a constructor error. I played around with the vite config and got it working. I found out that i have to specify:

ssr: {
   noExternal: ['@giraphql/core']
}

in svelte/vite config and tell vite to include it in the bundle rather than importing it.