-
Notifications
You must be signed in to change notification settings - Fork 1
feat(library): support typed graphql document #548
New issue
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
Conversation
There was a problem hiding this comment.
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 adds support for typed GraphQL documents via TypedDocumentNode to the useGQLQuery hook while maintaining backward compatibility with string queries. The implementation enables type-safe GraphQL queries when used with libraries like gql.tada or GraphQL Codegen, providing typed variables and return data.
Key Changes:
- Added function overloads to
useGQLQueryto support both string queries andTypedDocumentNodewith proper type inference - Added
@0no-co/graphql.weband@graphql-typed-document-node/coreas optional peer dependencies - Updated documentation with examples of compatible GraphQL type generation tools
Reviewed Changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| javascript-modules-library/src/hooks/useGQLQuery.ts | Added function overloads and runtime support for TypedDocumentNode with type parameter inference |
| javascript-modules-library/package.json | Added graphql.web and typed-document-node dependencies as optional peer dependencies |
| javascript-modules-library/README.md | Added documentation about typed document node support and compatible tooling |
| javascript-modules-engine/tests/cypress/e2e/ui/gqlTest.cy.ts | Updated test assertions to verify typed document node functionality |
| jahia-test-module/src/react/server/views/testGQL/TestGQL.tsx | Added test case demonstrating usage with parsed GraphQL documents |
| jahia-test-module/package.json | Added graphql dependency for test module |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
baptistegrimaud
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Idea for the future: when creating a new JS module with @jahia/create-module, should we let the developer opt in or out for typed GraphQL document? As interacting with Jahia GraphQL APIs is fairly common for customers.
|
Testing fully covered by automated tests |
Description
Small new feature!
This PR introduces typed GraphQL document support for our
useGQLQueryserver hook, without removing support for raw queries.Previous usage, unsafe
New usage, with gql.tada
It works with any library that produces a
TypedDocumentNode(added some examples in the readme)Usage in Luxe:
Checklist
Source code
Tests
Tip
Documentation to guide the reviews: How to do a code review