Skip to content

feat(data-helper): type graphql queries with gql.tada - #392

Merged
GauBen merged 4 commits into
mainfrom
gqltada
Aug 5, 2026
Merged

feat(data-helper): type graphql queries with gql.tada#392
GauBen merged 4 commits into
mainfrom
gqltada

Conversation

@GauBen

@GauBen GauBen commented Jul 27, 2026

Copy link
Copy Markdown
Member

Typing graphql queries provides better type-checking and auto-completion in consuming projects:

image

For instance, siteInfo used to be any and is now mostly typed


Approved on principle by @gflores-jahia

image

Removed 2 unused and non-exposed hooks

@github-actions

github-actions Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

🦜 Chachalog

@jahia/data-helper minor

Create a new entry online or run npx chachalog@0.5.2 prompt to create a new entry locally.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR migrates @jahia/data-helper’s static GraphQL documents from graphql-tag to gql.tada to provide typed queries/fragments (better TS autocomplete and type-checking), updates build/tsconfig to generate the required typing artifacts, and removes a couple of unused internal hooks.

Changes:

  • Added gql.tada initialization and TypeScript plugin config to type GraphQL documents from schema.graphql.
  • Refactored queries/fragments to use the new graphql() helper and updated fragment replacement typing.
  • Removed useSchemaFields and useDeepCompareMemoize, and updated dependency/resolution metadata + changelog entry.

Reviewed changes

Copilot reviewed 24 out of 25 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
yarn.lock Adds gql.tada and related deps; updates GraphQL resolution entries.
packages/data-helper/tsconfig.json Configures gql.tada TS plugin and generated output location.
packages/data-helper/src/legacy/Picker.tsx Switches legacy query creation from graphql-tag to gql.tada helper.
packages/data-helper/src/legacy/Picker.gql-fragments.ts Converts legacy fragments to gql.tada documents.
packages/data-helper/src/hooks/useTreeEntries/useTreeEntries.ts Tightens fragment key typing to keyof PredefinedFragments for safer use.
packages/data-helper/src/hooks/useTreeEntries/useTreeEntries.gql-queries.ts Converts TREE query to gql.tada and passes required fragment documents.
packages/data-helper/src/hooks/useSiteInfo/useSiteInfo.ts Types adaptSiteInfo with ResultOf from gql.tada.
packages/data-helper/src/hooks/useSiteInfo/useSiteInfo.gql-queries.ts Converts SiteInfo query to gql.tada.
packages/data-helper/src/hooks/useSchemaFields/useSchemaFields.tsx Removes unused hook.
packages/data-helper/src/hooks/useSchemaFields/useSchemaFields.gql-queries.ts Removes unused schema query document.
packages/data-helper/src/hooks/useNodeInfo/useNodeInfo.gql-queries.ts Converts NodeInfo query documents to gql.tada; minor TS cleanups.
packages/data-helper/src/hooks/useDeepCompareMemo/useDeepCompareMemo.ts Removes unused hook implementation.
packages/data-helper/src/hooks/useDeepCompareMemo/useDeepCompareMemo.test.js Removes tests for deleted hook.
packages/data-helper/src/hooks/useContentPreview/useContentPreview.ts Uses VariablesOf typing (currently via cast) for workspace.
packages/data-helper/src/hooks/useContentPreview/useContentPreview.gql-queries.ts Converts ContentPreview query to gql.tada.
packages/data-helper/src/gql/index.ts Introduces initGraphQLTada setup + shared ResultOf/VariablesOf exports.
packages/data-helper/src/gql/.gitignore Ignores generated graphql-live.d.ts output.
packages/data-helper/src/fragments/PredefinedFragments.ts Converts predefined fragments to gql.tada documents; adjusts fragment typing.
packages/data-helper/src/fragments/getSubNodesCountFragment.ts Converts dynamic fragment generation to gql.tada.
packages/data-helper/src/fragments/getPermissionFragment.ts Converts permission fragments to gql.tada.
packages/data-helper/src/fragments/getIsNodeTypeFragment.ts Converts node type fragments to gql.tada.
packages/data-helper/src/fragments/fragments.utils.ts Tightens fragment key typing to match PredefinedFragments keys.
packages/data-helper/package.json Adds gql.tada dep and runs gql.tada generate-output during build.
package.json Pins graphql via Yarn resolutions.
.chachalog/UG6bOuc4.md Adds a release note for the typing migration.

Comment thread packages/data-helper/package.json
Comment thread packages/data-helper/src/hooks/useSiteInfo/useSiteInfo.ts
Comment thread packages/data-helper/src/hooks/useContentPreview/useContentPreview.ts Outdated
Comment thread packages/data-helper/src/fragments/PredefinedFragments.ts Outdated
Comment thread packages/data-helper/src/gql/index.ts
Comment thread .chachalog/UG6bOuc4.md
@GauBen GauBen self-assigned this Jul 27, 2026

@gflores-jahia gflores-jahia left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Question: Would this force consumers e.g. jcontent to also use gql tada for any fragment references that was converted to gqltada ?

@GauBen

GauBen commented Aug 4, 2026

Copy link
Copy Markdown
Member Author

Nope, under the hood it's a graphql AST, same as graphql-tag. That's why we are not forced to mark this as a breaking change

@GauBen
GauBen merged commit 608d68f into main Aug 5, 2026
15 checks passed
@GauBen
GauBen deleted the gqltada branch August 5, 2026 10:19
This was referenced Aug 5, 2026
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