Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to the JSON Pointer standard for map field operations paths #56

Open
jaydenseric opened this issue Sep 9, 2021 · 2 comments
Open

Comments

@jaydenseric
Copy link
Owner

jaydenseric commented Sep 9, 2021

The IETF RFC 6901 “JSON Pointer” spec defines a string syntax for identifying a specific value within a JSON document.

Ideally, the GraphQL multipart request spec would use JSON pointer strings instead of less standard object-path strings for operations paths in the map field array.

Here is an example of the difference for the map field JSON for the batching example:

  {
    "0": [
-     "0.variables.file"
+     "/0/variables/file"
    ],
    "1": [
-     "1.variables.files.0"
+     "/1/variables/files/0"
    ],
    "2": [
-     "1.variables.files.1"
+     "/1/variables/files/1"
    ]
  }

Benefits of switching to the JSON Pointer format:

  • It has a detailed specification.
  • It’s a proposed web standard.
  • It should be more familiar to programers across languages.
  • There should be more tools and libraries available across languages to work with it, making implementations easier.

Cons:

  • It’s 1 character longer per path, leading to slightly larger request content lengths.
  • The / separators are “uglier” to people who would intuitively use . as that's what's used to reference properties within objects in languages such as JS.
  • A spec change like this would be a massive breaking change and would require simultaneous client and server implementation updates.

The benefits don't enable new features or capability and are probably not worth the pain. Until now there have been few, if any, complaints about the format for operations paths. It might make sense to leave this spec as it is until it moves to an official GraphQL Foundation GraphQL over HTTP spec (see graphql/graphql-over-http#7).

@Nickyle

This comment was marked as off-topic.

@jaydenseric

This comment was marked as off-topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants