Skip to content

"GraphQL Document Validation failed" appears when swithcing to multi-client mode #656

@AndrewBogdanovTSS

Description

@AndrewBogdanovTSS

Environment

- Operating System: Windows_NT                                                                                                                                                               
- Node Version:     v20.19.1                                                                                                                                                                 
- Nuxt Version:     3.17.4                                                                                                                                                                   
- CLI Version:      3.25.1                                                                                                                                                                   
- Nitro Version:    2.11.12                                                                                                                                                                  
- Package Manager:  [email protected]                                                                                                                                                              
- Builder:          -                                                                                                                                                                        
- User Config:      devtools, modules, graphql-client                                                                                                                                        
- Runtime Modules:  [email protected]                                                                                                                                               
- Build Modules:    -                                                                                                                                                                        

nuxt.config.ts

export default defineNuxtConfig({
  devtools: { enabled: true },
  modules: ['nuxt-graphql-client'],
  'graphql-client': {
    clients: {
      spacex: 'https://spacex-production.up.railway.app/',
      todos: 'https://nuxt-gql-server-2gl6xp7kua-ue.a.run.app/query'
    },
  },
});

Describe the bug

When I switch from single client to multi-client mode my queries start to fail validation. Looks like something preventing them from proper resolve to the correct client.
The issue is not present if instead of folder names I use postfix inside of the file itself.
queries/spacex/ships.gql -> validation fails
queries/ships.spacex.gql -> validation works well

Expected behaviour

queries/spacex/ships.gql -> should resolve to the correct client

Reproduction

https://github.com/AndrewBogdanovTSS/nuxt-graphql-test

Additional context

For some unfatomable reason I can't reproduce same issue iside stackblitz on exactly same repo.
Here it's is working fine: https://stackblitz.com/~/github.com/AndrewBogdanovTSS/nuxt-graphql-test?initialPath=/todos
The only extra dependency I see being installed in Stackblitz is @oxc-parser/binding-wasm32-wasi, but I don't think it affects this behavior

Logs

ERROR  Cannot start nuxt:  GraphQL Document Validation failed with 1 errors;                                                                                                 nuxi 14:31:20  
  Error 0: Cannot query field "todos" on type "Query". Did you mean "cores"?
    at d:/study/nuxt/nuxt-graphql-test/queries/todos/todos.gql:2:5

    at executeCodegen (/D:/study/nuxt/nuxt-graphql-test/node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected]/node_modules/@graphql-codegen/cli/esm/codegen.js:333:24)
    at async generate (/D:/study/nuxt/nuxt-graphql-test/node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected]/node_modules/@graphql-codegen/cli/esm/generate-and-save.js:99:25)
    at async generate (/D:/study/nuxt/nuxt-graphql-test/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/nuxt-graphql-client/dist/module.mjs:68:10)
    at async generateGqlTypes (/D:/study/nuxt/nuxt-graphql-test/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/nuxt-graphql-client/dist/module.mjs:347:46)
    at async setup (/D:/study/nuxt/nuxt-graphql-test/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/nuxt-graphql-client/dist/module.mjs:442:5)
    at async normalizedModule (/D:/study/nuxt/nuxt-graphql-test/node_modules/.pnpm/@[email protected][email protected]/node_modules/@nuxt/kit/dist/index.mjs:2169:17)
    at async installModule (/D:/study/nuxt/nuxt-graphql-test/node_modules/.pnpm/@[email protected][email protected]/node_modules/@nuxt/kit/dist/index.mjs:2494:276)
    at async initNuxt (/D:/study/nuxt/nuxt-graphql-test/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/nuxt/dist/shared/nuxt.Ipy8-4AT.mjs:5854:5)
    at async NuxtDevServer._load (/D:/study/nuxt/nuxt-graphql-test/node_modules/.pnpm/@[email protected]/node_modules/@nuxt/cli/dist/chunks/dev2.mjs:183:5)
    at async NuxtDevServer.load (/D:/study/nuxt/nuxt-graphql-test/node_modules/.pnpm/@[email protected]/node_modules/@nuxt/cli/dist/chunks/dev2.mjs:111:7)

    Error: GraphQL Document Validation failed with 1 errors;
    Error 0: Cannot query field "todos" on type "Query". Did you mean "cores"?
    at d:/study/nuxt/nuxt-graphql-test/queries/todos/todos.gql:2:5
    at codegen (/D:/study/nuxt/nuxt-graphql-test/node_modules/.pnpm/@[email protected][email protected]/node_modules/@graphql-codegen/core/esm/codegen.js:79:19)
    at async process (/D:/study/nuxt/nuxt-graphql-test/node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected]/node_modules/@graphql-codegen/cli/esm/codegen.js:285:60)
    at async Promise.all (index 0)
    at async /D:/study/nuxt/nuxt-graphql-test/node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected]/node_modules/@graphql-codegen/cli/esm/codegen.js:297:41
    at async /D:/study/nuxt/nuxt-graphql-test/node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected]/node_modules/@graphql-codegen/cli/esm/codegen.js:63:17
    at async Task.run (/D:/study/nuxt/nuxt-graphql-test/node_modules/.pnpm/[email protected]/node_modules/listr2/dist/index.js:960:11)
    at async node_modules\.pnpm\p[email protected]\node_modules\p-map\index.js:57:22

Might be related to #315

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions