Comments (9)
Again, I think this would be better served by HTTP content negotiation, in this case you could add Accept: application/graphql+jsoncrunch, application/graphql+json, application/json
or some such.
from graphql-over-http.
OK @benjie , you do have a point. It's much better and more conformant to the use case than utilising directives. However, i want to ask: are these mime-types standardised for use via the HTTP RFCs ?
from graphql-over-http.
Why does regular HTTP content negotiation not sufficiently fulfil this need?
from graphql-over-http.
Hello @benjie, yes, proactive HTTP content negotiation does in fact cover/include HTTP compression. However, one GraphQL client can request a GraphQL response with or without compression (e.g. gzip - because it supports stream compression; think @defer, @stream directives) depending on the size of the response but yes they can go hand-in-hand. Also, for most GraphQL clients and servers out there in the wild, the primarily popular Content-Type
is set to application/graphql
(which i think is in the process of being standardised) OR application/json
. In other words, JSON is preferred over say XML (which can also be a valid response content type format for GraphQL). But for compression, it should statutorily optional.
Furthermore, a directive might be beneficial to apply HTTP compression only above a given JSON response size on the server-side. I also do believe it has more benefits to the many way GraphQL responses could be delivered quickly than applying deduplication as an alternative which doesn't work with streamed content (HTTP 1.1 streaming) as the response has to be complete before deduplication can take place. HTTP compression can also be effectively disabled (by default) at the GraphQL level (especially if the GraphQL server utilises signed HTTP cookie(s) for authorization and hence needs to worry about CSRF and consequently the BREACH attack linked to HTTP-level compression).
from graphql-over-http.
Also, @benjie, another scenario will be to rename the directive from @httpCompressed to @compressed. This will enable deduplication to be used alongside HTTP compression (gzip). So, the GraphQL server may inspect the query and if it doesn't find directive that might suggest the use of HTTP 1.1 streaming to formulate the GraphQL response (think @defer, @stream directives), the @compressed directive makes use of deduplication else it makes use of HTTP compression (gzip - stream compression support). This can further standardise control over how and when deduplication is applied from the client-side.
from graphql-over-http.
When you say deduplication, what exactly are you referring to?
from graphql-over-http.
I mean removing duplicates that is and appears redundant in a given dataset as it applies to GraphQL response payloads (probably using logic like the one used here).
from graphql-over-http.
Not as far as I know; I don't think this specific spec would contain the GraphQL Crunch encoding for example, however this spec should be compatible with someone doing so. Much in the same way that the GraphQL Cursor Pagination Specification is not part of the GraphQL Spec, but is compatible with it. If changes are required to this spec to make it compatible I certainly support that 👍
Or if you mean the actual HTTP RFCs (rather than the GraphQL-over-HTTP RFC) then here's a good place to start your research: https://stackoverflow.com/a/11574673/141284
from graphql-over-http.
Closing this issue. There appears to be agreement that the solution is a combination of standard HTTP compression and HTTP content negotiation.
from graphql-over-http.
Related Issues (20)
- Spec references RFC7231 which is obsoleted HOT 4
- Response status code as `application/json` content HOT 5
- Clarify the use of HTTP GET and POST request HOT 2
- Status codes for unauthenticated OAuth errors HOT 1
- Optional query discussion HOT 13
- GraphQL request optional parameters HOT 2
- Kitchen sink HTTP requests HOT 3
- Allow non-UTF-8 encodings HOT 2
- What is well-formed response HOT 3
- Status codes 404 and 410 HOT 1
- Clarification for `Accept: */*` HOT 8
- Should we explicitly support `Content-Type: application/graphql`? HOT 13
- Should the query property really be required? HOT 1
- Make it clear that extra keys in the request/response payloads are not allowed HOT 2
- [2023-10] Add changes promoting spec to RFC 2 status
- [2023-10] Add RFC2 status to next GraphQL Spec WG HOT 1
- Create the "Action Item" issue template
- [2023-11] Add notes about security to GraphQL-over-HTTP spec HOT 8
- [2024-01-25] Contact Apollo about persisted operations appendix HOT 2
- What is the rationale for handling Invalid parameters as 400? HOT 15
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from graphql-over-http.