Skip to content

[client-preset] Make persisted docs default hashing algorithm sha256, and follow recommended format#10652

Merged
eddeee888 merged 5 commits intomaster-nextfrom
master-next-make-persisted-doc-default-sha256
Mar 24, 2026
Merged

[client-preset] Make persisted docs default hashing algorithm sha256, and follow recommended format#10652
eddeee888 merged 5 commits intomaster-nextfrom
master-next-make-persisted-doc-default-sha256

Conversation

@eddeee888
Copy link
Copy Markdown
Collaborator

@eddeee888 eddeee888 commented Mar 23, 2026

Description

This PR changes the default hashing algorithm for persisted docs to sha256 and follow the format in the GraphQL-over-http doc

Related #10496

Type of change

  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 23, 2026

🦋 Changeset detected

Latest commit: 16da7db

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@graphql-codegen/client-preset Major
@graphql-codegen/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@eddeee888 eddeee888 changed the title [client-preset] Make Client Preset default hashing algorithm sha256 and follow recommended format [client-preset] Make persisted docs default hashing algorithm sha256, and follow recommended format Mar 23, 2026
@eddeee888 eddeee888 changed the base branch from master to master-next March 23, 2026 11:31
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 23, 2026

🚀 Snapshot Release (alpha)

The latest changes of this PR are available as alpha on npm (based on the declared changesets):

Package Version Info
@graphql-codegen/cli 7.0.0-alpha-20260323113908-33f45bf480eca7cc9aef160da1e6e7c91c33a326 npm ↗︎ unpkg ↗︎
@graphql-codegen/core 6.0.0-alpha-20260323113908-33f45bf480eca7cc9aef160da1e6e7c91c33a326 npm ↗︎ unpkg ↗︎
@graphql-codegen/add 7.0.0-alpha-20260323113908-33f45bf480eca7cc9aef160da1e6e7c91c33a326 npm ↗︎ unpkg ↗︎
@graphql-codegen/fragment-matcher 7.0.0-alpha-20260323113908-33f45bf480eca7cc9aef160da1e6e7c91c33a326 npm ↗︎ unpkg ↗︎
@graphql-codegen/introspection 6.0.0-alpha-20260323113908-33f45bf480eca7cc9aef160da1e6e7c91c33a326 npm ↗︎ unpkg ↗︎
@graphql-codegen/schema-ast 6.0.0-alpha-20260323113908-33f45bf480eca7cc9aef160da1e6e7c91c33a326 npm ↗︎ unpkg ↗︎
@graphql-codegen/time 7.0.0-alpha-20260323113908-33f45bf480eca7cc9aef160da1e6e7c91c33a326 npm ↗︎ unpkg ↗︎
@graphql-codegen/visitor-plugin-common 7.0.0-alpha-20260323113908-33f45bf480eca7cc9aef160da1e6e7c91c33a326 npm ↗︎ unpkg ↗︎
@graphql-codegen/typescript-document-nodes 6.0.0-alpha-20260323113908-33f45bf480eca7cc9aef160da1e6e7c91c33a326 npm ↗︎ unpkg ↗︎
@graphql-codegen/gql-tag-operations 6.0.0-alpha-20260323113908-33f45bf480eca7cc9aef160da1e6e7c91c33a326 npm ↗︎ unpkg ↗︎
@graphql-codegen/typescript-operations 6.0.0-alpha-20260323113908-33f45bf480eca7cc9aef160da1e6e7c91c33a326 npm ↗︎ unpkg ↗︎
@graphql-codegen/typescript-resolvers 6.0.0-alpha-20260323113908-33f45bf480eca7cc9aef160da1e6e7c91c33a326 npm ↗︎ unpkg ↗︎
@graphql-codegen/typed-document-node 7.0.0-alpha-20260323113908-33f45bf480eca7cc9aef160da1e6e7c91c33a326 npm ↗︎ unpkg ↗︎
@graphql-codegen/typescript 6.0.0-alpha-20260323113908-33f45bf480eca7cc9aef160da1e6e7c91c33a326 npm ↗︎ unpkg ↗︎
@graphql-codegen/client-preset 6.0.0-alpha-20260323113908-33f45bf480eca7cc9aef160da1e6e7c91c33a326 npm ↗︎ unpkg ↗︎
@graphql-codegen/graphql-modules-preset 6.0.0-alpha-20260323113908-33f45bf480eca7cc9aef160da1e6e7c91c33a326 npm ↗︎ unpkg ↗︎
@graphql-codegen/testing 5.0.0-alpha-20260323113908-33f45bf480eca7cc9aef160da1e6e7c91c33a326 npm ↗︎ unpkg ↗︎
@graphql-codegen/plugin-helpers 7.0.0-alpha-20260323113908-33f45bf480eca7cc9aef160da1e6e7c91c33a326 npm ↗︎ unpkg ↗︎

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These got automatically generated in CI. I thought they were created on the master-next branch already 🤔
I will keep them here to avoid issues.

shasum.update(operation);
return shasum.digest('hex');

const algorithmPrefix = algorithm === 'sha256' ? 'sha256:' : '';
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @benjie @n1ru4l , the doc only says that when sha256 is used, it should be prefixed with sha256:. Therefore, I haven't applied this logic to sha1 . Keen to hear thoughts whether we should ?

Copy link
Copy Markdown
Contributor

@benjie benjie Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the spec:

The {prefix}
identifies the method of identification used. Applications may use their own
identification methods by ensuring that the prefix starts x-; otherwise, all
prefixes are reserved for reasons of future expansion
.

I would advise avoiding having a : in the doc ID at all for SHA1, but you can do x-sha1: or x-guild-sha1: or similar instead if you want. (Later you can propose we adopt sha1: as a supported prefix if you want.)

(What you have currently looks correct.)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah thanks for the extract from spec. Makes sense!
I'll keep it as-is then, thanks for your advice 🙏

@github-actions
Copy link
Copy Markdown
Contributor

💻 Website Preview

The latest changes are available as preview in: https://pr-10652.graphql-code-generator.pages.dev

@eddeee888 eddeee888 requested a review from n1ru4l March 23, 2026 11:38
Copy link
Copy Markdown
Collaborator

@n1ru4l n1ru4l left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😍

@eddeee888 eddeee888 merged commit a34d3cf into master-next Mar 24, 2026
@eddeee888 eddeee888 deleted the master-next-make-persisted-doc-default-sha256 branch March 24, 2026 11:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants