-
Notifications
You must be signed in to change notification settings - Fork 66
Provide clarifications on content type and serialization #83
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
Conversation
Add clarifications about how servers and clients should handle serialization format and content types.
|
|
||
| If another content type is preferable to a client, it MAY include an `Accept` HTTP header listing other acceptable content types in order of preference. In this case a client SHOULD include `application/graphql+json` in the list, according to their preferred priority. | ||
|
|
||
| If no `Accept` header is given, the server MUST respond with a content type of `application/graphql+json`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps weaken this statement and add non-normative note suggesting that this default be application/graphql+json to support legacy clients, to allow more wider implementations.
| Additionally, GraphQL MAY be used in combination with other HTTP request methods. | ||
| A server MUST accept either GET requests or POST requests. | ||
|
|
||
| A server SHOULD handle both GET and POST requests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is ambiguity here in that one line states that a server MUST accept either GET or POST requests and then that it should handle both.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It also seemed strange to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the difference between accept and handle?
| ## GET | ||
|
|
||
| For HTTP GET requests, the query parameters should be provided in the query component of the request URL in the form of | ||
| For HTTP GET requests, the query parameters MUST be provided in the query component of the request URL in the form of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I totally agree that this should be changed to MUST. I cannot imagine what could be done with a GET request that contained no operation.
|
|
||
| Servers MUST return an _Error response_ if a GET request includes a `query` and `operationName` (if present) describing an operation other than a query, such as a mutation or subscription. | ||
|
|
||
| Clients MUST NOT send GET requests for non-query operations. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these lines similar in meaning?
GET requests must ONLY be used for executing queries and MUST NOT be used for mutations or subscriptions.
and
Clients MUST NOT send GET requests for non-query operations.
If not, should we provide an example of a non-query operation?
README.md
Outdated
| the value of `Content-Type` header. | ||
| A GraphQL POST request instructs the server to perform a query, mutation or subscription operation. A GraphQL POST request should have a body which contains values of the request parameters encoded according to the value of `Content-Type` header of the request. | ||
|
|
||
| When sending a POST request to a GraphQL server a client MUST include a body. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line seems like it might be contradictory to the one above it. The first one says A GraphQL POST request should have a body..., but this one says MUST. Perhaps they could be combined?
| For HTTP GET requests, the query parameters MUST be provided in the query component of the request URL in the form of | ||
| `key=value` pairs with `&` symbol as a separator and both the key and value should have their "reserved" characters percent-encoded as specified in [section 2 of RFC3986](https://tools.ietf.org/html/rfc3986#section-2). | ||
| The unencoded value of the `variables` parameter should be represented as a JSON-encoded string. | ||
| The unencoded value of the `variables` parameter MUST be represented as a URL-encoded JSON string. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| The unencoded value of the `variables` parameter MUST be represented as a URL-encoded JSON string. | |
| The value of the `variables` parameter MUST be represented as a URL-encoded JSON object, with a name-value pair for each variable and its value. |
This is what the example shows: the unencoded/decoded value is a JSON object, the actual/encoded value is a URL-encoded JSON object. No double-encoding.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit pick (not blocking): JSON is a string (the N is for notation).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still confused by The unencoded value ... represented as a URL-encoded ....
Does this mean that I
- first have to translate the variables object into JSON,
- then URL-encode that JSON to get an un-encoded parameter value,
- and then again percent-encode the un-encoded parameter value before sending it in the HTTP request?
I hope percent/URL-encoding happens only once.
|
I intend to circle back to this and merge this PR before the July meeting. |
README.md
Outdated
|
|
||
| The GraphQL HTTP server SHOULD handle the HTTP GET and POST methods. | ||
| Additionally, GraphQL MAY be used in combination with other HTTP request methods. | ||
| A server MUST accept either GET requests or POST requests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have never encountered a server which doesn't support POST.
I think it should be MUST accept POST
|
There are some unaddressed comments on this PR and some significant time has passed. This PR will be merged soon. Please comment as desired. |
README.md
Outdated
| A server MUST accept either GET requests or POST requests. | ||
|
|
||
| A server SHOULD handle both GET and POST requests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| A server MUST accept either GET requests or POST requests. | |
| A server SHOULD handle both GET and POST requests. | |
| A server MUST handle POST requests, and MAY handle other HTTP methods, such as GET. |
Co-authored-by: Adrien Crivelli <adrien.crivelli@gmail.com> Co-authored-by: mmatsa <mmatsa@users.noreply.github.com>
|
Co-authored-by: Adrien Crivelli <adrien.crivelli@gmail.com> Co-authored-by: Ivan Maximov <sungam3r@yandex.ru>
|
@sjparsons Could you please resolve these conflicts and address the remaining comments? |
|
@sjparsons Could you review this PR to determine if it is still needed? If so, could you modify it to edit the spec file rather than the readme file? |
|
Attempted to revive with #161 |
This PR introduces some new rules in addition to addressing clarifications on the behavior of servers and clients with response to content types.
Most notably:
application/graphl+jsoncontent type.