Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"GraphQL Document Validation failed" prevents other build tools to fix the problem in dev mode #315

Open
sheggi opened this issue Mar 1, 2023 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@sheggi
Copy link

sheggi commented Mar 1, 2023

Environment

  • Operating System: Darwin
  • Node Version: v18.13.0
  • Nuxt Version: 3.1.0
  • Nitro Version: 2.0.0
  • Package Manager: yarn@1.22.19
  • Builder: vite
  • User Config: modules, runtimeConfig, css, components, postcss, vite
  • Runtime Modules: nuxt-graphql-client@0.2.24
  • Build Modules: -

Describe the bug

When starting nuxt dev the process stops/fails if any gql file has an invalid query.
This may happen if the schema changes meanwhile.

Error Message:

 ERROR  GraphQL Document Validation failed with 1 errors;

This would prevent any rebuild or regeneration of the gql file later during the startup.

Expected behaviour

In dev is true just log the error and continue.

In dev is false stop process to prevent build success.

Reproduction

No response

Additional context

No response

Logs

In this example, an invalid property xxx prevents codegen working properly

---
ERROR  GraphQL Document Validation failed with 1 errors;                                                                                                              16:28:37
  Error 0: Cannot query field "xxx" on type "Set_Components_ImageWithText".
    at ./gql-dx-playground/web/queries/generated/uri.gql:23:3

  Error 0: Cannot query field "xxx" on type "Set_Components_ImageWithText".
  at queries/generated/uri.gql:23:3
  at executeCodegen (node_modules/@graphql-codegen/cli/dist/shared/graphql-codegen-cli-nuxt.111a00cc.mjs:953:20)
  at async generate (node_modules/@graphql-codegen/cli/dist/shared/graphql-codegen-cli-nuxt.111a00cc.mjs:1254:23)
  at async generate (node_modules/nuxt-graphql-client/dist/module.mjs:62:10)
  at async generateGqlTypes (node_modules/nuxt-graphql-client/dist/module.mjs:340:46)
  at async setup (node_modules/nuxt-graphql-client/dist/module.mjs:443:5)
  at async normalizedModule (node_modules/@nuxt/kit/dist/index.mjs:167:5)
  at async installModule (node_modules/@nuxt/kit/dist/index.mjs:435:3)
  at async initNuxt (node_modules/nuxt/dist/index.mjs:2034:7)
  at async load (node_modules/nuxi/dist/chunks/dev.mjs:6797:9)
  at async Object.invoke (node_modules/nuxi/dist/chunks/dev.mjs:6858:5)

  Error: GraphQL Document Validation failed with 1 errors;
  Error 0: Cannot query field "xxx" on type "Set_Components_ImageWithText".
  at queries/generated/uri.gql:23:3
  at codegen (node_modules/@graphql-codegen/core/esm/codegen.js:69:19)
  at async process2 (node_modules/@graphql-codegen/cli/dist/shared/graphql-codegen-cli-nuxt.111a00cc.mjs:902:44)
  at async Promise.all (index 0)
  at async node_modules/@graphql-codegen/cli/dist/shared/graphql-codegen-cli-nuxt.111a00cc.mjs:915:27
  at async node_modules/@graphql-codegen/cli/dist/shared/graphql-codegen-cli-nuxt.111a00cc.mjs:682:11
  at async Task.run (node_modules/listr2/dist/index.js:960:11)
  at async node_modules/p-map/index.js:57:22
@sheggi sheggi added the bug Something isn't working label Mar 1, 2023
sheggi added a commit to sheggi/fork-nuxt-graphql-client that referenced this issue Mar 1, 2023
Don't stop `nuxt dev` if a GraphQl validation error happens.
Allow other build tools to fix the problem later on.
@Diizzayy Diizzayy self-assigned this Mar 5, 2023
@leaderit
Copy link

leaderit commented Mar 8, 2023

Same error in situation when a *.gql file contain more than one request.

If the file has been splitted into files which one request=one file, that error gone.

Parse gql file with more than one request effects the error

@sheggi
Copy link
Author

sheggi commented Mar 9, 2023

@leaderit If your concern is, that multiple requests in a single .gql file should be supported, you'll be better served raising your issue in the GraphQL code generation project https://the-guild.dev/graphql/codegen. This nuxt module just uses the codegen features and has no influence in it.

In your case, I'd rather guess that there is an error in your .gql file with multiple requests because I didn't have had any problems with multiple requests in one single file.

@arcs-
Copy link

arcs- commented Feb 21, 2024

I'd also really appreciate this, as it would allow for hot-reloading to continue to work even if errors have been typed.

This could also just be a configuration flag failOnErroror similar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants