Getting uncaught error on linting in codemirror
See original GitHub issueWhile 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:
- Created 3 years ago
- Comments:6 (2 by maintainers)
Top GitHub Comments
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…
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. 😉