Conversation
Contributor
Author
|
@Tobbe and others: one question I had is if the generators should be updated to detect if using TS and infer types as above. If som, we can make this a separate PR enhancement to update the generators. |
Contributor
|
@dthyresson Initial reaction, without looking at any code, is yes, we should, and yes, let’s do that in a separate PR 🙂 |
Contributor
Author
|
Tobbe
reviewed
Dec 28, 2023
Tobbe
approved these changes
Dec 28, 2023
dac09
added a commit
to dac09/redwood
that referenced
this pull request
Dec 29, 2023
…od into feat/api-skip-prebuild-try-2 * 'feat/api-skip-prebuild-try-2' of github.com:dac09/redwood: chore(router): Miniscule fixes chore(router): Move useMatch to its own file (redwoodjs#9770) Allow GraphQL documents to be typed with a TypedDocumentNode for fully-typed result and variables objects (redwoodjs#9619) chore(ci): retry detectChanges on error, and await result (redwoodjs#9772)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #9232
See the above issue for key points.
TLDR;
Before this PR, it wasn't possible to infer types from the
useQueryoruseMutationGraphQL hooks.Also,
TypedDocumentNodewas not conveniently exported from@redwoodjs/web(and is now).Now, you can do:
and infer types:
For context:
See https://the-guild.dev/blog/typed-document-node
TypedDocumentNode is a development tool that allows you to create fully typed DocumentNode objects. This means that by simply passing your GraphQL query, mutation, subscription, or fragment to a supporting GraphQL client library, you'll get fully-typed result and variables objects. This is made possible by TypeScript type inference.