-
Notifications
You must be signed in to change notification settings - Fork 33
How to precompute query hashes, store it, and use it to whitelist persisted queries. #28
Comments
We had the same problem while trying to implement persisted queries in our apps. I made a reproduction repository to clearly show that the hash generated by https://github.com/abumalick/persisted-queries-showcase You can clearly see the hash generated by And you can see the hash generated by If you want more details, I explained everything in the README Also I tried hard, exploring Help would be very appreciated. |
you can see this issue for more informations about this: apollographql/apollo-tooling#1117 |
isn't the point of automatic persisted queries to not use whitelist ? if i understand correctly you can use persistgraphql |
NB. persistgraphql is being deprecated in favour of apollo-link-persisted-queries and apollo-cli... |
@abumalick why use the If you know how to:
you are at home. I want to do the same but I am stuck with seemingly trivial task: how, for God's sake, use this After that I have to face another challenge: find someway to generate matching normalized stringified query (to use in my simple apollo link implementation) |
Manipulating the hash on the client side with Like you said, the real problem is making these hashes match the normalized queries generated by You should read this answer from apollo team if you didn't already: apollographql/apollo-tooling#1117 (comment) Personally I chose to not work on something that is not supported by the package maintainers, it will feel hacky and will probably not be stable. I stopped working on this at the moment. |
@abumalick Is then only the <step of normalized stringifying of a query> problematic to repeat in same way (actually: with same function) in the apollo link (which is then passed to the |
@abumalick https://www.apollographql.com/docs/platform/operation-registry/
... and it seems more clear now. This is an already made feature but for paid plans only, unfortunately (!) |
@abumalick Anyway, thanks for your reply! |
You are welcome. Sorry that I cannot help more. |
I've forked https://github.com/Cerberus/apollo-persisted-hash The result: top half is chrome screen-shot on network tab and the another one is part of white-list file that generated by |
Hello everyone, I have a script which traverse directories where I keep the That script in full readable/formatted form is just 56 lines of code and makes up ~80% of all code to make the whole scheme with frontend <--> backend safely work. I may share code snippets for the interested. |
Yes, it is interesting. Would you consider to opensource it ? If it is very simple to implement it may bring interest of the community. |
Yes, |
@bartero I am in the same exact situation, I think it would be nice for the community to create a tool to extract queries and a simple link for the server to filter. |
I just use the hashing function from this library to create a whitelist, and return a 403 if you make a request with a different hash. If you make a request using a valid hash but provide a query that doesn't correspond to the hash you'll get a
|
Hello, |
I want disallow arbitrary queries from client to prevent abusive queries.
How do I extract and compute query hashes and save it as a query white list file and use load it on apollo server to whitelist them?
I've tried apollo-cli apollo queries:extract, but its hashed value does not match the one created by apollo-link-persisted-queries.
The text was updated successfully, but these errors were encountered: