graphql-code-generator icon indicating copy to clipboard operation
graphql-code-generator copied to clipboard

[preset/client] Custom hash function for persisted operations

Open nathan-ahn opened this issue 1 year ago • 1 comments

Is your feature request related to a problem? Please describe.

I'd like to add more flexibility for persisted operations to allow developers to insert a custom hashing function instead of being limited to sha1 and sha256. This helps to avoid any issues requesting additional algorithms in the future, as well as supports additional use-cases. For example, I have a use-case in which we sign operations with a specific secret, and I'd like to re-use that for the persisted operation hash.

Describe the solution you'd like

An additional configuration option allowing developers to pass in a hashFunction. I've put together a proof of concept here. (Also, I'm happy to create a pull request for this).

Describe alternatives you've considered

Currently, I'm using this plugin which supports the use-case of generating an additional file with the operations and the hashes. For convenience, simplicity, and bundle size, I'd like to attach the hash to the operation document itself.

Is your feature request related to a problem? Please describe.

No response

nathan-ahn avatar Jun 09 '24 02:06 nathan-ahn

Instead of adding a nee config option we can make allow the existing hash algorithm property to be a function. Please feel free to send a PR with tests and documentation updates!

n1ru4l avatar Jun 09 '24 04:06 n1ru4l