Diizzayy / nuxt-graphql-client

⚡️ Minimal GraphQL Client + Code Generation for Nuxt3
https://nuxt-graphql-client.web.app
MIT License
364 stars 43 forks source link

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

Open sheggi opened 1 year ago

sheggi commented 1 year ago

Environment

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
leaderit commented 1 year ago

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 commented 1 year ago

@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- commented 9 months ago

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.

KillerJulian commented 4 days ago

@Diizzayy any update?