Giter Site home page Giter Site logo

Comments (9)

Geal avatar Geal commented on May 22, 2024 1

could we parse the query with apollo-rs and hash the result?

from router.

abernix avatar abernix commented on May 22, 2024 1

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.

o0Ignition0o avatar o0Ignition0o commented on May 22, 2024

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.

lrlna avatar lrlna commented on May 22, 2024

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

o0Ignition0o avatar o0Ignition0o commented on May 22, 2024

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.

Geal avatar Geal commented on May 22, 2024

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.

abernix avatar abernix commented on May 22, 2024

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

abernix avatar abernix commented on May 22, 2024

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

abernix avatar abernix commented on May 22, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.