nuxt-graphql-client icon indicating copy to clipboard operation
nuxt-graphql-client copied to clipboard

Demo app failing- Failed to load schema for "gql-sdk.ts"

Open colinscz opened this issue 2 years ago • 13 comments

Hi there

I just saw that the demo with the SpaceX API is failing under: https://stackblitz.com/github/diizzayy/nuxt-graphql-client-demo

I got the same error in local with the exact same setup.

colinscz avatar Jul 04 '22 13:07 colinscz

@cnschwarz Thanks you for pointing this out, it seems to have been caused by mismatching dependencies and should be fixed now.

If you still encounter this in your local setup, try deleting the node_modules folder along with either the yarn.lock or package-lock.json files.

also, adding the graphql dependency isn't needed, it was added to the demo as a workaround for a bug in the stackblitz environment

Diizzayy avatar Jul 04 '22 16:07 Diizzayy

@Diizzayy thanks for the quick response. Unfortunately I have the same error even after removing the graphql dependency deleting both node_modules and package-lock.json + a new fresh npm install after doing all this.

On startup I get the same error as described here: https://github.com/Diizzayy/nuxt-graphql-client/issues/57

colinscz avatar Jul 05 '22 12:07 colinscz

On startup I get the same error as described here: https://github.com/Diizzayy/nuxt-graphql-client/issues/57

@cnschwarz Can you post the exact error that you're getting so I can have a closer look? I'm unable to replicate the same behavior using the spacex demo api

Diizzayy avatar Jul 05 '22 13:07 Diizzayy

@Diizzayy sure thing man, here it is:

ERROR  Cannot start nuxt:  Something went wrong Failed to load schema for "gql-sdk.ts"                                                                                                                                       14:47:19
       Failed to load schema from https://api.spacex.land/graphql:                                                                                                                                                                   
                                                                                                                                                                                                                                     
       fetch failed                                                                                                                                                                                                                  
       TypeError: fetch failed                                                                                                                                                                                                       
   at Object.processResponse (C:\Develop\nuxt-app\node_modules\undici\lib\fetch\index.js:198:23)                                                                                                                              
   at C:\Develop\nuxt-app\node_modules\undici\lib\fetch\index.js:929:38                                                                                                                                                       
   at node:internal/process/task_queues:141:7
   at AsyncResource.runInAsyncScope (node:async_hooks:201:9)
   at AsyncResource.runMicrotask (node:internal/process/task_queues:138:8)
   at processTicksAndRejections (node:internal/process/task_queues:96:5)

       GraphQL Code Generator supports:
         - ES Modules and CommonJS exports (export as default or named export "schema")
         - Introspection JSON File
         - URL of GraphQL endpoint
         - Multiple files with type definitions (glob expression)
         - String in config file

       Try to use one of above options and run codegen again.



 Failed to load schema from https://api.spacex.land/graphql:

 fetch failed
 TypeError: fetch failed
 at Object.processResponse (node_modules\undici\lib\fetch\index.js:198:23)
 at node_modules\undici\lib\fetch\index.js:929:38
 at node:internal/process/task_queues:141:7
 at AsyncResource.runInAsyncScope (node:async_hooks:201:9)
 at AsyncResource.runMicrotask (node:internal/process/task_queues:138:8)
 at processTicksAndRejections (node:internal/process/task_queues:96:5)

 GraphQL Code Generator supports:
 - ES Modules and CommonJS exports (export as default or named export "schema")
 - Introspection JSON File
 - URL of GraphQL endpoint
 - Multiple files with type definitions (glob expression)
 - String in config file

 Try to use one of above options and run codegen again.


 at executeCodegen (/C:/Develop/nuxt-app/node_modules/@graphql-codegen/cli/index.mjs:1049:28)
 at processTicksAndRejections (node:internal/process/task_queues:96:5)
 at async generate (/C:/Develop/nuxt-app/node_modules/@graphql-codegen/cli/index.mjs:1357:25)
 at async generate (/C:/Develop/nuxt-app/node_modules/nuxt-graphql-client/dist/module.mjs:60:10)
 at async generateGqlTypes (/C:/Develop/nuxt-app/node_modules/nuxt-graphql-client/dist/module.mjs:280:22)
 at async setup (/C:/Develop/nuxt-app/node_modules/nuxt-graphql-client/dist/module.mjs:330:5)
 at async Object.normalizedModule (/C:/Develop/nuxt-app/node_modules/@nuxt/kit/dist/index.mjs:582:5)
 at async installModule (/C:/Develop/nuxt-app/node_modules/@nuxt/kit/dist/index.mjs:398:3)
 at async initNuxt (/C:/Develop/nuxt-app/node_modules/nuxt/dist/index.mjs:1334:7)
 at async load (/C:/Develop/nuxt-app/node_modules/nuxi/dist/chunks/dev.mjs:6741:9)

 Error: Failed to load schema
 at loadSchema (/C:/Develop/nuxt-app/node_modules/@graphql-codegen/cli/index.mjs:400:15)
 at processTicksAndRejections (node:internal/process/task_queues:96:5)
 at async /C:/Develop/nuxt-app/node_modules/@graphql-codegen/cli/index.mjs:924:65
 at async /C:/Develop/nuxt-app/node_modules/@graphql-codegen/cli/index.mjs:923:52
 at async /C:/Develop/nuxt-app/node_modules/@graphql-codegen/cli/index.mjs:810:21

colinscz avatar Jul 06 '22 07:07 colinscz

Same problem for me. Is there a work around ? Thanks for your time.

ElJere avatar Jul 08 '22 21:07 ElJere

In my case I can reach SpaceX API, but not mine. When I reach my API, I get the same error as above.

I use django-graphql and it works fine, I can reach it with Apollo or Postman.

Thanks!

tasiotas avatar Jul 21 '22 15:07 tasiotas

@tasiotas Can you run yarn nuxi info and post the output here along with the exact error that you're receiving when using your own API.

I've been completely unable to replicate this issue so any information at all would help in coming to a resolution.

Diizzayy avatar Jul 21 '22 17:07 Diizzayy

sure, ill get back to you with more info.

FYI, im on Windows, will give it a try on Linux on my VM. I think you had some issues on Win before.

tasiotas avatar Jul 21 '22 17:07 tasiotas

@tasiotas Thank you, also v0.1.6 is on the way with a hotfix for the useState regression. There was quite a large refactor recently

Diizzayy avatar Jul 21 '22 17:07 Diizzayy

I'm getting slightly different errors on dev and prod envs. Look for "unexpected token". I could give you access to my dev API point, hopefully you could repro the issue. Will need your IP for whitelisting.

Prod :

#27 8.146 
#27 8.146  ERROR  Failed to load schema for "gql-sdk.ts"
#27 8.146         Failed to load schema from https://dev.xxx.com/api:
#27 8.146 
#27 8.146         Unexpected token p in JSON at position 4
#27 8.146         SyntaxError: Unexpected token p in JSON at position 4
#27 8.146     at JSON.parse (<anonymous>)
#27 8.146     at file:///app/node_modules/@graphql-tools/url-loader/esm/index.js:241:37
#27 8.146     at processTicksAndRejections (node:internal/process/***k_queues:96:5)
#27 8.146     at async UrlLoader.load (file:///app/node_modules/@graphql-tools/url-loader/esm/index.js:547:29)
#27 8.146     at async file:///app/node_modules/@graphql-tools/load/esm/load-typedefs/load-file.js:11:39
#27 8.146     at async Promise.all (index 5)
#27 8.146     at async loadFile (file:///app/node_modules/@graphql-tools/load/esm/load-typedefs/load-file.js:9:9)
#27 8.146     at async file:///app/node_modules/@graphql-tools/load/esm/load-typedefs/collect-sources.js:144:25
#27 8.146 
#27 8.146         GraphQL Code Generator supports:
#27 8.146           - ES Modules and CommonJS exports (export as default or named export "schema")
#27 8.146           - Introspection JSON File
#27 8.146           - URL of GraphQL endpoint
#27 8.146           - Multiple files with type definitions (glob expression)
#27 8.146           - String in config file
#27 8.146 
#27 8.146         Try to use one of above options and run codegen again.
#27 8.146 
#27 8.146       
#27 8.146 
#27 8.146   Failed to load schema from https://dev.xxx.com/api:
#27 8.146   
#27 8.146   Unexpected token p in JSON at position 4
#27 8.146   SyntaxError: Unexpected token p in JSON at position 4
#27 8.146   at JSON.parse (<anonymous>)
#27 8.146   at node_modules/@graphql-tools/url-loader/esm/index.js:241:37
#27 8.146   at processTicksAndRejections (node:internal/process/***k_queues:96:5)
#27 8.146   at async UrlLoader.load (node_modules/@graphql-tools/url-loader/esm/index.js:547:29)
#27 8.146   at async node_modules/@graphql-tools/load/esm/load-typedefs/load-file.js:11:39
#27 8.146   at async Promise.all (index 5)
#27 8.146   at async loadFile (node_modules/@graphql-tools/load/esm/load-typedefs/load-file.js:9:9)
#27 8.146   at async node_modules/@graphql-tools/load/esm/load-typedefs/collect-sources.js:144:25
#27 8.146   
#27 8.146   GraphQL Code Generator supports:
#27 8.146   - ES Modules and CommonJS exports (export as default or named export "schema")
#27 8.146   - Introspection JSON File
#27 8.146   - URL of GraphQL endpoint
#27 8.146   - Multiple files with type definitions (glob expression)
#27 8.146   - String in config file
#27 8.146   
#27 8.146   Try to use one of above options and run codegen again.
#27 8.146   
#27 8.146   
#27 8.146   at executeCodegen (node_modules/@graphql-codegen/cli/esm/codegen.js:312:24)
#27 8.146   at processTicksAndRejections (node:internal/process/***k_queues:96:5)
#27 8.146   at async generate (node_modules/@graphql-codegen/cli/esm/generate-and-save.js:83:25)
#27 8.146   at async generate (node_modules/nuxt-graphql-client/dist/module.mjs:59:10)
#27 8.146   at async generateGqlTypes (node_modules/nuxt-graphql-client/dist/module.mjs:265:22)
#27 8.146   at async setup (node_modules/nuxt-graphql-client/dist/module.mjs:321:5)
#27 8.146   at async Object.normalizedModule (node_modules/@nuxt/kit/dist/index.mjs:607:5)
#27 8.146   at async installModule (node_modules/@nuxt/kit/dist/index.mjs:432:3)
#27 8.146   at async initNuxt (node_modules/nuxt/dist/index.mjs:1423:7)
#27 8.146   at async loadNuxt (node_modules/nuxt/dist/index.mjs:1451:5)
#27 8.146   
#27 8.146   Error: Failed to load schema
#27 8.146   at loadSchema (node_modules/@graphql-codegen/cli/esm/load.js:43:15)
#27 8.146   at processTicksAndRejections (node:internal/process/***k_queues:96:5)
#27 8.146   at async node_modules/@graphql-codegen/cli/esm/codegen.js:181:69
#27 8.146   at async node_modules/@graphql-codegen/cli/esm/codegen.js:180:56
#27 8.146   at async node_modules/@graphql-codegen/cli/esm/codegen.js:63:21
#27 8.146   at async Task.run (node_modules/listr2/dist/index.js:960:11)
#27 8.146   at async node_modules/p-map/index.js:57:22
#27 8.146 
#27 8.146 error Command failed with exit code 1.
#27 8.206 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
#27 ERROR: executor failed running [/bin/sh -c yarn build]: exit code: 1

Local

Nuxt CLI v3.0.0-rc.6                                                                                                                                                                                                                                                                                                    10:45:27
                                                                                                                                                                                                                                                                                                                        10:45:29
  > Local:    https://local.xxx.com:3000/


 ERROR  Cannot start nuxt:  Failed to load schema for "gql-sdk.ts"                                                                                                                                                                                                                                                      10:45:31
        Failed to load schema from https://dev.xxx.com/api:

        Unexpected token < in JSON at position 1
        SyntaxError: Unexpected token < in JSON at position 1
    at JSON.parse (<anonymous>)
    at file:///C:/Work/xxx/Website/Code/xxx/Frontend/node_modules/.pnpm/@[email protected][email protected]/node_modules/@graphql-tools/url-loader/esm/index.js:241:37
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async UrlLoader.load (file:///C:/Work/xxx/Website/Code/xxx/Frontend/node_modules/.pnpm/@[email protected][email protected]/node_modules/@graphql-tools/url-loader/esm/index.js:547:29)
    at async file:///C:/Work/xxx/Website/Code/xxx/Frontend/node_modules/.pnpm/@[email protected][email protected]/node_modules/@graphql-tools/load/esm/load-typedefs/load-file.js:11:39
    at async Promise.all (index 5)
    at async loadFile (file:///C:/Work/xxx/Website/Code/xxx/Frontend/node_modules/.pnpm/@[email protected][email protected]/node_modules/@graphql-tools/load/esm/load-typedefs/load-file.js:9:9)
    at async file:///C:/Work/xxx/Website/Code/xxx/Frontend/node_modules/.pnpm/@[email protected][email protected]/node_modules/@graphql-tools/load/esm/load-typedefs/collect-sources.js:144:25

        GraphQL Code Generator supports:
          - ES Modules and CommonJS exports (export as default or named export "schema")
          - Introspection JSON File
          - URL of GraphQL endpoint
          - Multiple files with type definitions (glob expression)
          - String in config file

        Try to use one of above options and run codegen again.



  Failed to load schema from https://dev.xxx.com/api:

  Unexpected token < in JSON at position 1
  SyntaxError: Unexpected token < in JSON at position 1
  at JSON.parse (<anonymous>)
  at /C:/Work/xxx/Website/Code/xxx/Frontend/node_modules/.pnpm/@[email protected][email protected]/node_modules/@graphql-tools/url-loader/esm/index.js:241:37
  at runMicrotasks (<anonymous>)
  at processTicksAndRejections (node:internal/process/task_queues:96:5)
  at async UrlLoader.load (/C:/Work/xxx/Website/Code/xxx/Frontend/node_modules/.pnpm/@[email protected][email protected]/node_modules/@graphql-tools/url-loader/esm/index.js:547:29)
  at async /C:/Work/xxx/Website/Code/xxx/Frontend/node_modules/.pnpm/@[email protected][email protected]/node_modules/@graphql-tools/load/esm/load-typedefs/load-file.js:11:39
  at async Promise.all (index 5)
  at async loadFile (/C:/Work/xxx/Website/Code/xxx/Frontend/node_modules/.pnpm/@[email protected][email protected]/node_modules/@graphql-tools/load/esm/load-typedefs/load-file.js:9:9)
  at async /C:/Work/xxx/Website/Code/xxx/Frontend/node_modules/.pnpm/@[email protected][email protected]/node_modules/@graphql-tools/load/esm/load-typedefs/collect-sources.js:144:25

  GraphQL Code Generator supports:
  - ES Modules and CommonJS exports (export as default or named export "schema")
  - Introspection JSON File
  - URL of GraphQL endpoint
  - Multiple files with type definitions (glob expression)
  - String in config file

  Try to use one of above options and run codegen again.


  at executeCodegen (/C:/Work/xxx/Website/Code/xxx/Frontend/node_modules/.pnpm/@[email protected][email protected]/node_modules/@graphql-codegen/cli/esm/codegen.js:312:24)
  at runMicrotasks (<anonymous>)
  at processTicksAndRejections (node:internal/process/task_queues:96:5)
  at async generate (/C:/Work/xxx/Website/Code/xxx/Frontend/node_modules/.pnpm/@[email protected][email protected]/node_modules/@graphql-codegen/cli/esm/generate-and-save.js:83:25)
  at async generate (/C:/Work/xxx/Website/Code/xxx/Frontend/node_modules/.pnpm/[email protected]/node_modules/nuxt-graphql-client/dist/module.mjs:59:10)
  at async generateGqlTypes (/C:/Work/xxx/Website/Code/xxx/Frontend/node_modules/.pnpm/[email protected]/node_modules/nuxt-graphql-client/dist/module.mjs:265:22)
  at async setup (/C:/Work/xxx/Website/Code/xxx/Frontend/node_modules/.pnpm/[email protected]/node_modules/nuxt-graphql-client/dist/module.mjs:321:5)
  at async Object.normalizedModule (/C:/Work/xxx/Website/Code/xxx/Frontend/node_modules/.pnpm/@[email protected]/node_modules/@nuxt/kit/dist/index.mjs:607:5)
  at async installModule (/C:/Work/xxx/Website/Code/xxx/Frontend/node_modules/.pnpm/@[email protected]/node_modules/@nuxt/kit/dist/index.mjs:432:3)
  at async initNuxt (/C:/Work/xxx/Website/Code/xxx/Frontend/node_modules/.pnpm/[email protected][email protected]/node_modules/nuxt/dist/index.mjs:1423:7)

  Error: Failed to load schema
  at loadSchema (/C:/Work/xxx/Website/Code/xxx/Frontend/node_modules/.pnpm/@[email protected][email protected]/node_modules/@graphql-codegen/cli/esm/load.js:43:15)
  at runMicrotasks (<anonymous>)
  at processTicksAndRejections (node:internal/process/task_queues:96:5)
  at async /C:/Work/xxx/Website/Code/xxx/Frontend/node_modules/.pnpm/@[email protected][email protected]/node_modules/@graphql-codegen/cli/esm/codegen.js:181:69
  at async /C:/Work/xxx/Website/Code/xxx/Frontend/node_modules/.pnpm/@[email protected][email protected]/node_modules/@graphql-codegen/cli/esm/codegen.js:180:56
  at async /C:/Work/xxx/Website/Code/xxx/Frontend/node_modules/.pnpm/@[email protected][email protected]/node_modules/@graphql-codegen/cli/esm/codegen.js:63:21
  at async Task.run (/C:/Work/xxx/Website/Code/xxx/Frontend/node_modules/.pnpm/[email protected]/node_modules/listr2/dist/index.js:960:11)
  at async node_modules\.pnpm\[email protected]\node_modules\p-map\index.js:57:22

tasiotas avatar Jul 21 '22 17:07 tasiotas

I could give you access to my dev API point

This would certainly help, contact me on discord ( Diizzayy#1964 ) or shoot me a quick email ( [email protected] ), I'll send you the IP for my dev server and hopefully we can figure out the true underlying cause here

Diizzayy avatar Jul 21 '22 18:07 Diizzayy

Hey @Diizzayy and @tasiotas any new developments on this issue? :)

colinscz avatar Sep 22 '22 07:09 colinscz

It was mistake on my end. Badly configured API. This client works fine.

tasiotas avatar Sep 22 '22 15:09 tasiotas

Closing as the suspected underlying issue here has been addressed in a prior release.

Diizzayy avatar Nov 25 '22 17:11 Diizzayy