Bug: Duplicate typename error when saving types file
corydeppen opened this issue · comments
Description
I'm unsure if these are related, but the schema in a fresh Vite app with Fuse doesn't contain the example user
field after running fuse dev
and an error is thrown when saving the User.ts
file.
pnpm create vite test-fuse --template react-ts
cd test-fuse
pnpm create fuse-app
pnpm fuse dev
The server starts as expected but the user field isn't present in the schema. Hitting save on /types/User.ts
throws the following error:
Error when evaluating SSR module /types/User.ts:
|- PothosSchemaError: Duplicate typename: Another type with name User already exists.
at new PothosError (file:///path/to/node_modules/.pnpm/@pothos+core@3.41.0_graphql@16.8.1/node_modules/@pothos/core/esm/errors.js:4:9)
at new PothosSchemaError (file:///path/to/node_modules/.pnpm/@pothos+core@3.41.0_graphql@16.8.1/node_modules/@pothos/core/esm/errors.js:10:9)
at ConfigStore.addTypeConfig (file:///path/to/node_modules/.pnpm/@pothos+core@3.41.0_graphql@16.8.1/node_modules/@pothos/core/esm/config-store.js:116:19)
at SchemaBuilder.objectType (file:///path/to/node_modules/.pnpm/@pothos+core@3.41.0_graphql@16.8.1/node_modules/@pothos/core/esm/builder.js:59:26)
at ImplementableLoadableNodeRef.implement (file:///path/to/node_modules/.pnpm/@pothos+core@3.41.0_graphql@16.8.1/node_modules/@pothos/core/esm/refs/object.js:30:29)
at SchemaBuilder.loadableNode (file:///path/to/node_modules/.pnpm/@pothos+plugin-dataloader@3.17.2_@pothos+core@3.41.0_dataloader@2.2.2_graphql@16.8.1/node_modules/@pothos/plugin-dataloader/esm/schema-builder.js:59:9)
at Module.node (file:///path/to/node_modules/.pnpm/fuse@0.11.4_next@14.1.0_react@18.2.0_typescript@5.3.3/node_modules/fuse/dist/builder.mjs:183:25)
at eval (/path/to/types/User.ts:5:40)
at async instantiateModule (file:///path/to/node_modules/.pnpm/vite@5.0.12/node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:50861:9)
Versions
- TypeScript Version: 5.3.3
- Fuse version: 0.11.4
I've followed these exact steps and was not able to reproduce the issue, mind providing a minimal reproducible example?
The following example app was created using the default Vite template in Stackblitz. I only ran npx create-fuse-app
to add Fuse.
https://stackblitz.com/edit/vitejs-vite-1dizhg?file=types%2FUser.ts
Once the app is running, stop the terminal, run npx fuse dev
, and then browse to the server once it's running. You should see that the user
query field isn't present in the documentation explorer. Making a change to the User.ts
file and saving should also display the duplicate typename error in the terminal.
Solved in 0.12.1, thank you so much for the reproduction https://stackblitz.com/edit/vitejs-vite-mvvebx?file=package.json