Skip to content

Conversation

@sjparsons
Copy link
Contributor

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:

  1. Specifies that servers MUST support JSON serialization and the associated application/graphl+json content type.
  2. Describes how servers and clients should interact with respect to content types.
  3. Separates examples in both GET and POST requests to their own section heading

Add clarifications about how servers and clients should handle
serialization format and content types.
@sjparsons sjparsons mentioned this pull request Apr 24, 2020
7 tasks
@sjparsons sjparsons mentioned this pull request Apr 24, 2020

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`.
Copy link
Contributor Author

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.
Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor

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
Copy link
Contributor

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.
Copy link
Contributor

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.
Copy link
Contributor

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Copy link
Contributor

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).

Copy link
Contributor

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.

@sjparsons sjparsons added this to the July 2020 milestone Jun 30, 2020
@sjparsons
Copy link
Contributor Author

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.

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

@ghmcadams
Copy link
Contributor

There are some unaddressed comments on this PR and some significant time has passed. This PR will be merged soon. Please comment as desired.

Base automatically changed from master to main February 2, 2021 20:06
README.md Outdated
Comment on lines 106 to 108
A server MUST accept either GET requests or POST requests.

A server SHOULD handle both GET and POST requests.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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>
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Feb 17, 2021

CLA Missing ID

ghmcadams and others added 2 commits February 17, 2021 09:11
Co-authored-by: Adrien Crivelli <adrien.crivelli@gmail.com>
Co-authored-by: Ivan Maximov <sungam3r@yandex.ru>
@ghmcadams
Copy link
Contributor

@sjparsons Could you please resolve these conflicts and address the remaining comments?

@ghmcadams
Copy link
Contributor

@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?

@ghmcadams
Copy link
Contributor

Attempted to revive with #161

ghmcadams added a commit to ghmcadams/graphql-over-http that referenced this pull request Jun 1, 2021
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

Successfully merging this pull request may close these issues.

9 participants