question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't load schema from URL

See original GitHub issue

Describe the bug

ESLint throws an error despite me having the options set correctly:

[Error - 3:35:15 PM] ESLint stack trace:
[Error - 3:35:15 PM] Error: Rule 'known-type-names' requires 'parserOptions.schema' to be set and schema to be loaded. See http://bit.ly/graphql-eslint-schema for more info
Occurred while linting C:\backup\QCSD\packages\client\src\components\SimulationDetails\DetailCardAnalyses\DetailCardAnalyses.graphql:1
Rule: "@graphql-eslint/known-type-names"
    at requireGraphQLSchemaFromContext (C:\backup\QCSD\node_modules\@graphql-eslint\eslint-plugin\index.js:192:15)
    at Document (C:\backup\QCSD\node_modules\@graphql-eslint\eslint-plugin\index.js:408:62)
    at ruleErrorHandler (C:\backup\QCSD\node_modules\eslint\lib\linter\linter.js:1107:28)
    at C:\backup\QCSD\node_modules\eslint\lib\linter\safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (C:\backup\QCSD\node_modules\eslint\lib\linter\safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (C:\backup\QCSD\node_modules\eslint\lib\linter\node-event-generator.js:297:26)
    at NodeEventGenerator.applySelectors (C:\backup\QCSD\node_modules\eslint\lib\linter\node-event-generator.js:326:22)
    at NodeEventGenerator.enterNode (C:\backup\QCSD\node_modules\eslint\lib\linter\node-event-generator.js:340:14)
    at CodePathAnalyzer.enterNode (C:\backup\QCSD\node_modules\eslint\lib\linter\code-path-analysis\code-path-analyzer.js:795:23)

.eslintrc.json

  "overrides": [
    {
      "files": ["*.graphql"],
      "rules": {
        "prettier/prettier": "error",
        "@graphql-eslint/known-type-names": "error"
      },
      "parser": "@graphql-eslint/eslint-plugin",
      "plugins": ["@graphql-eslint"],
      "parserOptions": {
        "operations": "./src/**/*.graphql",
        "schema": "http://localhost:4000/api"
      }
      //"extends": "plugin:@graphql-eslint/schema-recommended"
    }
  ]

(Things work fine if I comment out the @graphql-eslint rule.)

I can access the graphql api just fine in the browser, so I know it’s running.

Environment:

  • OS: Windows
  • @graphql-eslint/3.8.0:
  • NodeJS: 16.13.1
  • Editor: VS Code 1.64.2

Is there a debug flag I can turn on for better logging? Not sure where things are failing

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
B2o5Tcommented, Feb 23, 2022

hi @kaysond, I know only that graphql-eslint uses @graphq-tools/url-loader for loading graphql schema via URL endpoint. url-loader uses sync-fetch package for loading schema in sync mode. Try to debug sync-fetch package in node_modules folder.

In this place https://github.com/larsgw/sync-fetch/blob/main/index.js#L123 you should receive your response payload

0reactions
kaysondcommented, Feb 22, 2022

@B2o5T is there a way to log the result of the http request? This is necessary to debug the issue with extensions

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to load schema from a URL · Issue #525 - GitHub
Describe the bug When trying to load my schema from an external URL, I get an error coming from node-fetch: TypeError: Expected signal...
Read more >
All of my .json files have problems loading reference/schema ...
Here's the exact error I'm getting. Problems loading reference 'https://schemastore.azurewebsites.net/schemas/json/package.json': Unable to load ...
Read more >
Understanding schema errors | HESA
Schema errors prevent the validation being run in full because the file cannot be read. This means that errors cannot be traced to...
Read more >
GraphQL Code Libraries, Tools and Services
urql is a GraphQL client that exposes a set of helpers for several frameworks. It's built to be highly customisable and versatile so...
Read more >
Loading GraphQL Schemas from Different Sources
Schema and document loading doesn't work non Node.js environments, ... const { UrlLoader } = require('@graphql-tools/url-loader') const ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found