Skip to content

Commit 4db4e50

Browse files
authored
Grammar tweaks and add paragraph re: URL limit (#257)
1 parent 859cc07 commit 4db4e50

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

rfcs/PersistedOperations.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ With Persisted Operations we have a few goals:
88

99
- Reduce request transfer size (GraphQL documents have a deterministic size)
1010
- Support caching (avoid running into max-url size constraints when using the `GET` HTTP method)
11-
- Lock down the amount of request permutations (the server can choose to only accept persisted operations it is aware of)
11+
- Lock down the number of request permutations (the server can choose to only accept persisted operations it is aware of)
1212

1313
## Flow
1414

@@ -26,19 +26,23 @@ After stringifying we can produce a SHA-256 hash of the stringified document whi
2626

2727
When sending the persisted operation we will potentially be violating the current Request parameters where we say that `query`
2828
is a _required_ property. The proposal here is to add an additional _optional_ property `documentId` which has to be present
29-
when `query` isn't. We disallow both `documentId` and `query` being absent when performing a GraphQL Request.
29+
when `query` isn't. We disallow both `documentId` and `query` to be absent when performing a GraphQL Request.
3030

3131
The `documentId` would be the hashed representation of the stringified GraphQL document.
3232

33-
We can send all the operation kinds as a persisted operation, however we should make the distinction between `query` and `mutation`.
33+
We can send all the operation kinds as a persisted operation, however, we should make the distinction between `query` and `mutation`.
3434
By definition `query` contains cacheable data so we can send this either as a `GET` or a `POST` so we follow the spec, however a
3535
`mutation` represents side-effects so we should only send this as a `POST` request when leveraging persisted operations.
3636

37+
When sending GraphQL variables along with a `query` operation over the `GET` HTTP method, the URL size limit (typically 2048
38+
characters) should be considered if the URL's query string is to be employed to encode these GraphQL variables. If this is an
39+
issue, one should consider utilizing a `POST` request's `body` or an HTTP header to encode these variables.
40+
3741
### Executing
3842

3943
When a server receives a request containing only `documentId` it is assumed that the server can perform this lookup, when the lookup
40-
fails the server responds with a status-code 400 or 404 and denies the request. When the persisted operation can be found the server
41-
can assume that it's dealing with a valid GraphQL document, however the schema could have changed so the server _should_ still validate
44+
fails the server responds with a status code 400 or 404 and denies the request. When the persisted operation can be found the server
45+
can assume that it's dealing with a valid GraphQL document, however, the schema could have changed so the server _should_ still validate
4246
before executing.
4347

4448
## Automatic persisted operations
@@ -47,13 +51,13 @@ We can expand persisted operations with an "Automatic" mode which was initially
4751
with the automatic mode we have no expectation of the server being aware of our `documentId` before sending it. This means we
4852
can "teach" the server about the documents we are sending on the fly.
4953

50-
For hashing and sending the persisted operation we keep the aforementioned flow, however the flow after is altered as the server
51-
responds with a status-code 200 and a GraphQLError containing a message of `PersistedOperationNotFound` when it supports persisted
54+
For hashing and sending the persisted operation we keep the aforementioned flow, however, the flow after is altered as the server
55+
responds with a status code 200 and a GraphQLError containing a message of `PersistedOperationNotFound` when it supports persisted
5256
operations, when persisted operations are unsupported the server can change the error message to `PersistedOperationNotSupported`.
5357

5458
The client is made aware of the server not knowing the document we are dealing with by means of this error, the client can now send
5559
a new request containing both `documentId` and `query` in the parameters to make the server aware of the correlation. The server can
56-
verify that the `documentId` and `query` are correctly being associated by performing the stringify and hash steps, this to avoid
60+
verify that the `documentId` and `query` are correctly being associated by performing the stringify and hash steps, to avoid
5761
malicious actors inserting faux associations.
5862

5963
The server can now save the association between the `documentId` and `query` for future requests.

0 commit comments

Comments
 (0)