-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(client-preset): persisted document custom hash function (#9996)
* Custom hash function * Moving hash function to existing hashAlgorithm field * Docs for hash algorithm function + test to match example in docs * [preset/client] Adding changeset for custom hash function * Added configuration example to changeset
- Loading branch information
1 parent
5e594ef
commit 99f449c
Showing
5 changed files
with
342 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- | ||
"@graphql-codegen/client-preset": patch | ||
"website": patch | ||
--- | ||
|
||
Added configuration to allow for custom hash functions for persisted documents in the client preset | ||
|
||
### Example | ||
```ts filename="codegen.ts" {10-12} | ||
import { type CodegenConfig } from '@graphql-codegen/cli' | ||
|
||
const config: CodegenConfig = { | ||
schema: 'schema.graphql', | ||
documents: ['src/**/*.tsx'], | ||
generates: { | ||
'./src/gql/': { | ||
preset: 'client', | ||
presetConfig: { | ||
persistedDocuments: { | ||
hashAlgorithm: operation => { | ||
const shasum = crypto.createHash('sha512') | ||
shasum.update(operation) | ||
return shasum.digest('hex') | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.