Conversation
🦜 Chachalog
|
There was a problem hiding this comment.
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.tadainitialization and TypeScript plugin config to type GraphQL documents fromschema.graphql. - Refactored queries/fragments to use the new
graphql()helper and updated fragment replacement typing. - Removed
useSchemaFieldsanduseDeepCompareMemoize, 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. |
gflores-jahia
left a comment
There was a problem hiding this comment.
Question: Would this force consumers e.g. jcontent to also use gql tada for any fragment references that was converted to gqltada ?
|
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 |
Typing graphql queries provides better type-checking and auto-completion in consuming projects:
For instance,
siteInfoused to beanyand is now mostly typedApproved on principle by @gflores-jahia
Removed 2 unused and non-exposed hooks