We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@graphql-codegen/client-preset
When using hashAlgorithm: (operation) => {} in persistedDocuments config, i got string without \n and \t.
hashAlgorithm: (operation) => {}
persistedDocuments
\n
\t
However, they actually generated with \t and \n in gql.ts. That produces bug, when hash of query is wrong, and my backend validating that.
gql.ts
There is not
Is it neccecary?
Should pass \t and \n symbols into hashing function, also maybe should do that by default when using hashAlgorithm: 'sha256'.
hashAlgorithm: 'sha256'
No response
graphql
@graphql-codegen/*
import crypto from 'node:crypto' import { join, resolve } from 'node:path' import process from 'node:process' import { addTypenameSelectionDocumentTransform } from '@graphql-codegen/client-preset' import type { CodegenConfig } from '@graphql-codegen/cli' const schemaDir = resolve(join(process.cwd(), '..', '..', 'apps', 'api-gql', 'schema', '*.graphqls')) const config: CodegenConfig = { config: { scalars: { Upload: 'File', }, }, schema: schemaDir, documents: ['src/api/**/*.ts'], ignoreNoDocuments: true, // for better experience with the watcher generates: { './src/gql/': { preset: 'client', config: { useTypeImports: true, }, presetConfig: { persistedDocuments: { hashAlgorithm: (operation) => { const hash = computeQueryHash(operation) return hash }, }, }, documentTransforms: [addTypenameSelectionDocumentTransform], }, }, } export default config function computeQueryHash(query) { const hash = crypto.createHash('sha256') hash.update(query) return hash.digest('hex') }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Which packages are impacted by your issue?
@graphql-codegen/client-preset
Describe the bug
When using
hashAlgorithm: (operation) => {}
inpersistedDocuments
config, i got string without\n
and\t
.However, they actually generated with
\t
and\n
ingql.ts
. That produces bug, when hash of query is wrong, and my backend validating that.Your Example Website or App
There is not
Steps to Reproduce the Bug or Issue
Is it neccecary?
Expected behavior
Should pass
\t
and\n
symbols into hashing function, also maybe should do that by default when usinghashAlgorithm: 'sha256'
.Screenshots or Videos
No response
Platform
graphql
version: 16.8.1@graphql-codegen/*
version(s): "@graphql-codegen/cli": "5.0.3", "@graphql-codegen/client-preset": "4.5.1",Codegen Config File
Additional context
No response
The text was updated successfully, but these errors were encountered: