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.

Getting uncaught error on linting in codemirror

See original GitHub issue

While trying to add codemirror (using react-codemirror2) with graphql linting and hinting I ran into an issue where whenever I write anything that would trigger linting (even just {\n\t}) or hinting, long error pops up, I can run graphiql on the API and it works just fine, but when I try to do it myself it fails as followed:

Error: Name "__objects" must not begin with "__", which is reserved by GraphQL introspection.

Name "__actions" must not begin with "__", which is reserved by GraphQL introspection.

Name "__str__" must not begin with "__", which is reserved by GraphQL introspection.

Name "__actions" must not begin with "__", which is reserved by GraphQL introspection.

Name "__str__" must not begin with "__", which is reserved by GraphQL introspection.

Name "__actions" must not begin with "__", which is reserved by GraphQL introspection.

First thing I tried to look into was whether my schema was correct but I obtain it through getIntrospectionQuery() and buildClientSchema() so I would expect it to be correct (ran it through JSON.stringify for a little bit of simplification, but it appears to be okay GraphQLschema). the problem of course is, that for example “__str__” aren’t even in the schema, so I don’t know where the error comes from. It’s probably on my side, but I ran out of ideas on what it could be.

The schema:

    "_queryType": "Query",
    "_mutationType": "Mutation",
    "_subscriptionType": null,
    "_directives": ["@include", "@skip"],
    "_typeMap": {
        "Query": "Query",
        "Bookmark": "Bookmark",
        "Int": "Int",
        "Book": "Book",
        "String": "String",
        "Boolean": "Boolean",
        "BookmarkList": "BookmarkList",
        "BookmarkFiltersInput": "BookmarkFiltersInput",
        "ActionInfo": "ActionInfo",
        "Duration": "Duration",
        "BookList": "BookList",
        "BookFiltersInput": "BookFiltersInput",
        "BookGetById2Input": "BookGetById2Input",
        "ObjectInfo": "ObjectInfo",
        "Mutation": "Mutation",
        "BookCreateInput": "BookCreateInput",
        "BookUpdateInput": "BookUpdateInput",
        "BookmarkCreateInput": "BookmarkCreateInput",
        "BookmarkUpdateInput": "BookmarkUpdateInput",
        "__Schema": "__Schema",
        "__Type": "__Type",
        "__TypeKind": "__TypeKind",
        "__Field": "__Field",
        "__InputValue": "__InputValue",
        "__EnumValue": "__EnumValue",
        "__Directive": "__Directive",
        "__DirectiveLocation": "__DirectiveLocation"
    },
    "_subTypeMap": {},
    "_implementationsMap": {}
}

My codemirror options:

                        mode: "graphql",
                        smartIndent: true,
                        lint: {
                            schema: schema,
                        },
                        lineNumbers: true,
                        hintOptions: {
                            schema: schema,
                            closeOnUnfocus: false,
                            completeSingle: false,
                        }

And most of the traceback:

validate.mjs:48 

Uncaught Error: Name "__objects" must not begin with "__", which is reserved by GraphQL introspection.

/** Error discription above **/
    at assertValidSchema (validate.mjs:48)
    at validate (validate.mjs:33)
    at validateWithCustomRules (validateWithCustomRules.ts:49)
    at validateQuery (getDiagnostics.ts:111)
    at Module.getDiagnostics (getDiagnostics.ts:97)
    at lint.ts:46
    at startLinting (lint.js:154)
    at CodeMirror.<anonymous> (lint.js:252)
    at codemirror.js:3927
    at CodeMirror.setOption (codemirror.js:8238)
    at index.js:415
    at Array.forEach (<anonymous>)

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
ladal1commented, Mar 26, 2021

I think I did figure it out, the problem wasn’t necessarily inside graphql, graphiql or react - it was the fact that development react has explicit errors, while graphiql just ate them up (only letting you see them inside console).

The schema did contain reserved commands starting with “__” which the graphql schema validation throwing up as wrong. I would appreciate the option to maybe disable this check or at least option to only log it (as it’s difficult to catch it happening when graphql is added into codemirror…), as the schema was otherwise completely valid. But It’s not in any way important and this issue can be closed…

0reactions
ladal1commented, Apr 21, 2021

@benjie @leebyron I think this user may be helped out by some specific spec discussion? It’s a bit over my head today tbh! Haha

While tempting, my only quarry once I figured out the problem (Dev server handling of exceptions) was with the schema parsing actually requiring with exception the reserved “__” namespace to be empty, I wouldn’t expect such limitation to be enforced like that. 😉

Read more comments on GitHub >

github_iconTop Results From Across the Web

Accessing linting errors on update - v6 - CodeMirror
Hey,. I would like to figure out after editor update, if there are any linting errors. Is there a way to do that?...
Read more >
How to fix "Error: HTMLHint not found, ..., CodeMirror HTML ...
I'm able to get CSS and JS linting working fine but HTML linting is not working. I'm still getting the " Error: HTMLHint...
Read more >
Including csslint.js causes "require is not defined" errors #666
I've been using csslint.js in a CodeMirror project for several months without a problem. A few days ago, I started getting "Uncaught ......
Read more >
Code Editing Improvements in WordPress 4.9
Get started quickly with our tickets marked as good first bugs for new ... CodeMirror also supports linting to actually add explicit error...
Read more >
Solved: Linting our code? - ServiceNow Community
I can see Servicenow embeds Code mirror, which has an eslint plugin. Is there a documented or undocumented way to add our configuration...
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