-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[typescript-resolvers] Add meta field to typescript-resolvers plugin's output #9961
Conversation
🦋 Changeset detectedLatest commit: 861a158 The changes in this PR will be included in the next version bump. This PR includes changesets to release 10 packages
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 |
🚀 Snapshot Release (
|
Package | Version | Info |
---|---|---|
@graphql-codegen/visitor-plugin-common |
5.2.0-alpha-20240515093252-861a1585c727fb832ea0d17c816649b7091e7da6 |
npm ↗︎ unpkg ↗︎ |
@graphql-codegen/typescript-document-nodes |
4.0.7-alpha-20240515093252-861a1585c727fb832ea0d17c816649b7091e7da6 |
npm ↗︎ unpkg ↗︎ |
@graphql-codegen/gql-tag-operations |
4.0.7-alpha-20240515093252-861a1585c727fb832ea0d17c816649b7091e7da6 |
npm ↗︎ unpkg ↗︎ |
@graphql-codegen/typescript-operations |
4.2.1-alpha-20240515093252-861a1585c727fb832ea0d17c816649b7091e7da6 |
npm ↗︎ unpkg ↗︎ |
@graphql-codegen/typescript-resolvers |
4.1.0-alpha-20240515093252-861a1585c727fb832ea0d17c816649b7091e7da6 |
npm ↗︎ unpkg ↗︎ |
@graphql-codegen/typed-document-node |
5.0.7-alpha-20240515093252-861a1585c727fb832ea0d17c816649b7091e7da6 |
npm ↗︎ unpkg ↗︎ |
@graphql-codegen/typescript |
4.0.7-alpha-20240515093252-861a1585c727fb832ea0d17c816649b7091e7da6 |
npm ↗︎ unpkg ↗︎ |
@graphql-codegen/client-preset |
4.2.6-alpha-20240515093252-861a1585c727fb832ea0d17c816649b7091e7da6 |
npm ↗︎ unpkg ↗︎ |
@graphql-codegen/graphql-modules-preset |
4.0.7-alpha-20240515093252-861a1585c727fb832ea0d17c816649b7091e7da6 |
npm ↗︎ unpkg ↗︎ |
@graphql-codegen/plugin-helpers |
5.0.4-alpha-20240515093252-861a1585c727fb832ea0d17c816649b7091e7da6 |
npm ↗︎ unpkg ↗︎ |
💻 Website PreviewThe latest changes are available as preview in: https://bd098451.graphql-code-generator.pages.dev |
.changeset/new-radios-flash.md
Outdated
@@ -0,0 +1,6 @@ | |||
--- | |||
'@graphql-codegen/visitor-plugin-common': patch |
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.
I assume that patch
because this is kinda considered an internal API so it will not effect other users?
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.
Yes, internal API is also my thinking here. I'm happy to go either minor
or path
in this case though 🙂
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.
should we only output these in generated content if we have DEBUG
enabled? or maybe just output based on some config file?
To me doesn't make much difference cause I don't commit generated artifacts from codegen to a repo, but those who do it will create a big diff once they upgrade?
Hi @saihaj , the intention is that The main use for these is to report metadata of the run for advanced use cases. For example, server preset needs to know the name of generated types so it can generate its import statements. Here's an example generated file from server preset: import type { UserResolvers } from './../../types.generated';
export const User: UserResolvers = {
/* Implement User resolver logic here */
}; If user applies import type { user_resolvers } from './../../types.generated'; // Server Preset can look into the `meta` field to know `user_resolvers` is the name of the generated type
export const User: user_resolvers = {
/* Implement User resolver logic here */
}; |
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.
Approved, but I would use minor instead of patch as @dotansimha suggested 😇
6d02c96
to
861a158
Compare
Description
Currently, we don't know easily what has been generated from the run without parsing through the output's content.
This PR adds a new optional
meta
to allow plugins to report certain things about the run.This PR also makes
@graphql-codegen/typescript-resolvers
report generated resolver type names - after applyingnamingConvention
- tometa
. This allows plugins/presets (e.g. Server Preset) that relies on@graphql-codegen/typescript-resolvers
plugin to import the generated resolver types without trying to match thenamingConvention
logic manually.Type of change
Please delete options that are not relevant.
How Has This Been Tested?