Comments (9)
could we parse the query with apollo-rs and hash the result?
from router.
For caches right now I believe we just use a hash (SHA-256, perhaps?) of the string of the raw operation sent by the client. (I also don't know that variations in ignored tokens — e.g., spaces, etc. — are particularly prevalent in the wild right now or something we need to optimize for.
from router.
We might wanna double check with @lrlna, if I got their presentation right apollo rs keeps all of the tokens around, so I'm not sure this would suffice.
OTOH I cannot find any normalization step happening on queries in federation, (poke @abernix maybe you know where/if it happens ?)
I think we can start by hashing the parsed result, and we can then iterate on it and normalize the query before we parse it via apollo-rs!
from router.
@o0Ignition0o yes, the AST is lossless: i.e. we keep all the whitespace and other ignored tokens. Eventually, once we have semantic analysis in place, you should be able to store the schema object which would mark ignored tokens as insignificant, therefore two queries that only differ in whitespace would be identical. This is, however, a few months out.
On the other hand, if a query has changed, even if it's just whitespace, how do you currently find out if that's the only thing that has changed, therefore is syntactically identical to what's already in a cache? Don't you have to do a brand new parse anyways?
from router.
I suspect we would have to indeed :(
(I just found the conversation we had on proj-router about that, and it seems to be what stripIgnoredCharacters does)
If a couple of \n
and whitespaces strip is good enough we might be able to do that, otherwise i'm not sure that's too useful for our caching usecase
from router.
On the other hand, if a query has changed, even if it's just whitespace, how do you currently find out if that's the only thing that has changed, therefore is syntactically identical to what's already in a cache? Don't you have to do a brand new parse anyways?
My (untested) assumption is that query planning and introspection could cost a lot more than the parsing and normalization step
from router.
(Of course, we can eventually and there are a variety of reasons to do so, particularly as the weight of what we cache increases!)
from router.
(Continuing my parentheticals, rather than just editing the previous post): I should also note that the current cache store for these things are all bound LRU caches.
from router.
Closing as I know our more-practical nera-term answer this is going be "do introspection in Rust", which is in-progress thanks to @SimonSapin in apollographql/apollo-rs#758.
from router.
Related Issues (20)
- docs: broken link for "tech notes" HOT 3
- Rust v1.78.0 router-bridge startup panic HOT 1
- trace_id check to accepts dashes as UUID format HOT 6
- distributed Query Plan cache may be poisoned by experimental query plan features HOT 2
- Proposal: Remove apollo-router-scaffold
- Add test that limits max size of router json schema
- Native plugins not called on invalid GraphQL query since 1.45
- `early_cancel` is not documented HOT 1
- document private response caching
- Request/Response body size metric per operation name
- Rhai Scripting - how to get subgraph response code HOT 1
- Query plan cache key follow up
- High increase of base memory usage by Router v1.46.0 HOT 1
- Subgraph batching clears the context when responding with an array of the same operation HOT 1
- Graphql requests return non-graphql responses
- Add support for studio trace id selector in telemetry HOT 1
- Metrics overflow should be logged as a warning rather than error
- Support unix time in ms in rhai scripts
- Hot reload downtime under load
- Add standard attributes to all logs from context keys
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 router.