graphql-type-json icon indicating copy to clipboard operation
graphql-type-json copied to clipboard

JSONObject can not parse objects with string keys

Open ilovett opened this issue 5 years ago • 2 comments

Considering that a JSON Object can have keys can have non alpha numerical characters like . or -, those should be wrapped in a string in javascript.

I would assume that passing JSONObject input where: { "dot.path.thing": { name: 123 }} should still pass as valid input JSONObject, but the parser throws this error:

Syntax Error GraphQL request (3:30) Expected Name, found String

I'm assuming it's some kind of limitation though... Must all JSONObject keys be Name ?

ilovett avatar Aug 28 '20 00:08 ilovett

I don't think I actually have any control over this at all. I think it's just whatever the graphql-js AST parser does.

taion avatar Aug 28 '20 00:08 taion

Has anyone found a solution to this? I am trying to store a JSON Schema in my database via a graphql mutation, but JSON Schema's inherently have keys that start with "$" like "$schema" and "$ref".

YeomansIII avatar Mar 30 '23 17:03 YeomansIII