- #10449
8258f1fThanks @eddeee888! - Add addInterfaceFieldResolverTypes option to support custom Interface resolver inheritance
- #10412
accdab6Thanks @thekevinbrown! - Add special handling for identifiers that consist entirely of _ characters when transformUnderscore is true. This prevents _ values in GraphQL enums from being emitted without identifers in the resulting types.
-
#10218
140298aThanks @eddeee888! - BREAKING CHANGES: Do not generate __isTypeOf for non-implementing types or non-union members -
#10218
140298aThanks @eddeee888! - Remove deprecated config optiondedupeFragments -
#10218
140298aThanks @eddeee888! - Remove NameNode override -
#10218
140298aThanks @eddeee888! - BREAKING CHANGE: Use Record<PropertyKey, never> instead of {} for empty object type -
#10218
140298aThanks @eddeee888! - Ensure Federation Interfaces have__resolveReferenceif they are resolvable entitiesBREAKING CHANGES: Deprecate
onlyResolveTypeForInterfacesbecause majority of use cases cannot implement resolvers in Interfaces. BREAKING CHANGES: DeprecategenerateInternalResolversIfNeeded.__resolveReferencebecause types do not have__resolveReferenceif they are not Federation entities or are not resolvable. Users should not have to manually set this option. This option was put in to wait for this major version. -
#10218
140298aThanks @eddeee888! - BREAKING CHANGE: Improve Federation Entity's resolvers' parent param type: These types were using reference types inline. This makes it hard to handle mappers. The Parent type now all comes from ParentResolverTypes to make handling mappers and parent types simpler. -
#10218
140298aThanks @eddeee888! - Bump dependencies major versions:- dependency-graph to v1
-
#10218
140298aThanks @eddeee888! - Fixmappersusage with Federationmapperswas previously used as__resolveReference's first param (usually called "reference"). However, this is incorrect becausereferenceinterface comes directly from@keyand@requiresdirectives. This patch fixes the issue by creating a newFederationTypestype and use it as the base for federation entity types when being used to type entity references.BREAKING CHANGES: No longer generate
UnwrappedObjectutility type, as this was used to support the wrong previously generated type. -
#10218
140298aThanks @eddeee888! - Drop Node 18 support
- #10218
140298aThanks @eddeee888! - Report to meta user defined objects whether they have isTypeOf resolver
-
#10218
140298aThanks @eddeee888! - Update @requires type -
#10218
140298aThanks @eddeee888! - Fix fields or object types marked with @external being wrongly generated -
Updated dependencies [
140298a,140298a,140298a,140298a,140298a,140298a,140298a,140298a,140298a]:- @graphql-codegen/plugin-helpers@6.0.0
- #10315
f6909d1Thanks @eddeee888! - Implement semanticNonNull custom directive
- #10302
d8566c0Thanks @eddeee888! - Fix Apollo unmask directive incorrectly generating fragmentRefs
-
#10230
60dd72fThanks @eddeee888! - Fix generateInternalResolversIfNeeded.__resolveReference making the resolver required__resolveReference's default behaviour when not declared is to pass the ref to subsequent resolvers i.e. becoming theparent. So, it means we don't have to make this resolver required.This patch makes
__resolveReferenceoptional whengenerateInternalResolversIfNeeded.__resolveReferenceis set to true.
- #10163
fa64fbfThanks @jerelmiller! - Add support for Apollo Client@unmaskdirective with fragment masking.
- #10187
1617e3cThanks @gilgardosh! - Fix: type naming for imported enums
-
#9989
55a1e9eThanks @eddeee888! - AddgenerateInternalResolversIfNeededoptionThis option can be used to generate more correct types for internal resolvers. For example, only generate
__resolveReferenceif the federation object has a resolvable@key.In the future, this option can be extended to support other internal resolvers e.g.
__isTypeOfis only generated for implementing types and union members. -
#10141
a235051Thanks @eddeee888! - Add avoidCheckingAbstractTypesRecursively to avoid checking and generating abstract types recursivelyFor users that already sets recursive default mappers e.g.
Partial<{T}>orDeepPartial<{T}>, having both options on will cause a nested loop which eventually crashes Codegen. In such case, settingavoidCheckingAbstractTypesRecursively: trueallows users to continue to use recursive default mappers as before.
- Updated dependencies [
55a1e9e]:- @graphql-codegen/plugin-helpers@5.1.0
-
#10077
3f4f546Thanks @eddeee888! - Extendconfig.avoidOptionsto support query, mutation and subscriptionPreviously,
config.avoidOptions.resolverswas being used to make query, mutation and subscription fields non-optional. Now,config.avoidOptions.query,config.avoidOptions.mutationandconfig.avoidOptions.subscriptioncan be used to target the respective types.
- #10014
79fee3cThanks @eddeee888! - Fix object types with fields being abstract types not pointing to resolver types correctly
- #10007
808ada5Thanks @eddeee888! - Add generated resolvers map type name to typescript-resolvers plugin meta
- #10019
14ce39eThanks @vhfmag! - Improve code generation performance by computingClientSideBaseVisitor'sfragmentsGraphonce at instantiation time.
- #9961
dfc5310Thanks @eddeee888! - Update typescript-resolvers to report generated resolver types in the run to meta field in the output
-
#9944
156cc2bThanks @eddeee888! - Add _ prefix to generatedRefTypeinResolversInterfaceTypesandResolversUnionTypesas it is sometimes unused -
#9962
b49457bThanks @eddeee888! - Fix interface mappers not working in nested/self-referencing scenarios -
Updated dependencies [
dfc5310]:- @graphql-codegen/plugin-helpers@5.0.4
- #9842
ed9c205Thanks @henryqdineen! - properly handle aliased conditionals
- #9845
53f270aThanks @productdevbook! - path starts with "#"
-
Updated dependencies [
4e69568]:- @graphql-codegen/plugin-helpers@5.0.3
- #9673
7718a8113Thanks @maclockard! - Respect avoidOptionals when all arguments are optional
- #9811
d8364e045Thanks @saihaj! - fix: out-of-memory crash (fixes #7720) perf: implement a caching mechanism that makes sure the type originating at the same location is never generated twice, as long as the combination of selected fields and possible types matches feat: implementextractAllFieldsToTypes: booleanfeat: implementprintFieldsOnNewLines: boolean
-
#9811
d8364e045Thanks @saihaj! - dependencies updates:- Updated dependency
tslib@~2.6.0↗︎ (from~2.5.0, independencies)
- Updated dependency
-
#9811
d8364e045Thanks @saihaj! - Avoid reading from null values when selection sets only contain fragments. -
Updated dependencies [
d8364e045]:- @graphql-codegen/plugin-helpers@5.0.2
-
#9497
2276708d0Thanks @eddeee888! - Revert default ID scalar input type to stringWe changed the ID Scalar input type from
stringtostring | numberin the latest major version oftypescriptplugin. This causes issues for server plugins (e.g. typescript-resolvers) that depends ontypescriptplugin. This is because the scalar type needs to be manually inverted on setup which is confusing.
-
#9375
ba84a3a27Thanks @eddeee888! - Implement Scalars with input/output typesIn GraphQL, Scalar types can be different for client and server. For example, given the native GraphQL ID:
- A client may send
stringornumberin the input - A client receives
stringin its selection set (i.e output) - A server receives
stringin the resolver (GraphQL parsesstringornumberreceived from the client tostring) - A server may return
stringornumber(GraphQL serializes the value tostringbefore sending it to the client )
Currently, we represent every Scalar with only one type. This is what codegen generates as base type:
export type Scalars = { ID: string }
Then, this is used in both input and output type e.g.
export type Book = { __typename?: 'Book' id: Scalars['ID'] // Output's ID can be `string` 👍 } export type QueryBookArgs = { id: Scalars['ID'] // Input's ID can be `string` or `number`. However, the type is only `string` here 👎 }
This PR extends each Scalar to have input and output:
export type Scalars = { ID: { input: string | number output: string } }
Then, each input/output GraphQL type can correctly refer to the correct input/output scalar type:
export type Book = { __typename?: 'Book' id: Scalars['ID']['output'] // Output's ID can be `string` 👍 } export type QueryBookArgs = { id: Scalars['ID']['input'] // Input's ID can be `string` or `number` 👍 }
Note that for
typescript-resolvers, the type of ID needs to be inverted. However, the referenced types in GraphQL input/output types should still work correctly:export type Scalars = { ID: { input: string; output: string | number; } } export type Book = { __typename?: "Book"; id: Scalars["ID"]['output']; // Resolvers can return `string` or `number` in ID fields 👍 }; export type QueryBookArgs = { id: Scalars["ID"]['input']; // Resolvers receive `string` in ID fields 👍 }; export type ResolversTypes = { ID: ID: ResolverTypeWrapper<Scalars['ID']['output']>; // Resolvers can return `string` or `number` in ID fields 👍 } export type ResolversParentTypes = { ID: Scalars['ID']['output']; // Resolvers receive `string` or `number` from parents 👍 };
Config changes:
- Scalars option can now take input/output types:
config: { scalars: { ID: { input: 'string', output: 'string | number' } } }
- If a string is given (instead of an object with input/output fields), it will be used as both input and output types:
config: { scalars: { ID: 'string' // This means `string` will be used for both ID's input and output types } }
- BREAKING CHANGE: External module Scalar types need to be an object with input/output fields
config: { scalars: { ID: './path/to/scalar-module' } }
If correctly, wired up, the following will be generated:
// Previously, imported `ID` type can be a primitive type, now it must be an object with input/output fields import { ID } from './path/to/scalar-module' export type Scalars = { ID: { input: ID['input']; output: ID['output'] } }
BREAKING CHANGE: This changes Scalar types which could be referenced in other plugins. If you are a plugin maintainer and reference Scalar, please update your plugin to use the correct input/output types.
- A client may send
-
bb66c2a31Thanks @n1ru4l! - Require Node.js>= 16. Drop support for Node.js 14
-
#9196
3848a2b73Thanks @beerose! - Add@deferdirective supportWhen a query includes a deferred fragment field, the server will return a partial response with the non-deferred fields first, followed by the remaining fields once they have been resolved.
Once start using the
@deferdirective in your queries, the generated code will automatically include support for the directive.// src/index.tsx import { graphql } from './gql' const OrdersFragment = graphql(` fragment OrdersFragment on User { orders { id total } } `) const GetUserQuery = graphql(` query GetUser($id: ID!) { user(id: $id) { id name ...OrdersFragment @defer } } `)
The generated type for
GetUserQuerywill have information that the fragment is incremental, meaning it may not be available right away.// gql/graphql.ts export type GetUserQuery = { __typename?: 'Query'; id: string; name: string } & ({ __typename?: 'Query' } & { ' $fragmentRefs'?: { OrdersFragment: Incremental<OrdersFragment> } })
Apart from generating code that includes support for the
@deferdirective, the Codegen also exports a utility function calledisFragmentReady. You can use it to conditionally render components based on whether the data for a deferred fragment is available:const OrdersList = (props: { data: FragmentType<typeof OrdersFragment> }) => { const data = useFragment(OrdersFragment, props.data); return ( // render orders list ) }; function App() { const { data } = useQuery(GetUserQuery); return ( {data && ( <> {isFragmentReady(GetUserQuery, OrdersFragment, data) && <OrdersList data={data} />} </> )} ); } export default App;
-
#9339
50471e651Thanks @AaronMoat! - Add excludeTypes config to resolversNonOptionalTypenameThis disables the adding of
__typenamein resolver types for any specified typename. This could be useful e.g. if you're wanting to enable this for all new types going forward but not do a big migration.Usage example:
const config: CodegenConfig = { schema: 'src/schema/**/*.graphql', generates: { 'src/schema/types.ts': { plugins: ['typescript', 'typescript-resolvers'], config: { resolversNonOptionalTypename: { unionMember: true, excludeTypes: ['MyType'] } } } } }
-
#9229
5aa95aa96Thanks @eddeee888! - Use generic to simplify ResolversUnionTypesThis follows the
ResolversInterfaceTypes's approach where theRefTypegeneric is used to refer back toResolversTypesorResolversParentTypesin cases of nested Union types -
#9304
e1dc75f3cThanks @esfomeado! - Added support for disabling suffixes on Enums. -
#9229
5aa95aa96Thanks @eddeee888! - Extract interfaces to ResolversInterfaceTypes and add to resolversNonOptionalTypenameResolversInterfaceTypesis a new type that keeps track of a GraphQL interface and its implementing types.
For example, consider this schema:
extend type Query { character(id: ID!): CharacterNode } interface CharacterNode { id: ID! } type Wizard implements CharacterNode { id: ID! screenName: String! spells: [String!]! } type Fighter implements CharacterNode { id: ID! screenName: String! powerLevel: Int! }
The generated types will look like this:
export type ResolversInterfaceTypes<RefType extends Record<string, unknown>> = { CharacterNode: Fighter | Wizard } export type ResolversTypes = { // other types... CharacterNode: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['CharacterNode']> Fighter: ResolverTypeWrapper<Fighter> Wizard: ResolverTypeWrapper<Wizard> // other types... } export type ResolversParentTypes = { // other types... CharacterNode: ResolversInterfaceTypes<ResolversParentTypes>['CharacterNode'] Fighter: Fighter Wizard: Wizard // other types... }
The
RefTypegeneric is used to reference back toResolversTypesandResolversParentTypesin some cases such as field returning a Union.resolversNonOptionalTypenamealso affectsResolversInterfaceTypes
Using the schema above, if we use
resolversNonOptionalTypenameoption:const config: CodegenConfig = { schema: 'src/schema/**/*.graphql', generates: { 'src/schema/types.ts': { plugins: ['typescript', 'typescript-resolvers'], config: { resolversNonOptionalTypename: true // Or `resolversNonOptionalTypename: { interfaceImplementingType: true }` } } } }
Then, the generated type looks like this:
export type ResolversInterfaceTypes<RefType extends Record<string, unknown>> = { CharacterNode: (Fighter & { __typename: 'Fighter' }) | (Wizard & { __typename: 'Wizard' }) } export type ResolversTypes = { // other types... CharacterNode: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['CharacterNode']> Fighter: ResolverTypeWrapper<Fighter> Wizard: ResolverTypeWrapper<Wizard> // other types... } export type ResolversParentTypes = { // other types... CharacterNode: ResolversInterfaceTypes<ResolversParentTypes>['CharacterNode'] Fighter: Fighter Wizard: Wizard // other types... }
-
#9449
4d9ea1a5aThanks @n1ru4l! - dependencies updates:- Updated dependency
@graphql-tools/optimize@^2.0.0↗︎ (from^1.3.0, independencies) - Updated dependency
@graphql-tools/relay-operation-optimizer@^7.0.0↗︎ (from^6.5.0, independencies) - Updated dependency
@graphql-tools/utils@^10.0.0↗︎ (from^9.0.0, independencies)
- Updated dependency
-
#9414
ca02ad172Thanks @beerose! - Include nested fragments in string documentMode -
#9369
5950f5a68Thanks @asmundg! - Output valid type names with mergeFragmentTypes -
Updated dependencies [
4d9ea1a5a,f46803a8c,63827fabe,bb66c2a31]:- @graphql-codegen/plugin-helpers@5.0.0
-
#9301
386cf9044Thanks @wassim-k! - Fix fragment imports for near-operation-file with graphQLTag -
#9231
402cb8ac0Thanks @eddeee888! - Implement resolversNonOptionalTypename for mapper cases
-
#9146
9f4d9c5a4Thanks @eddeee888! - [typescript-resolvers] AddresolversNonOptionalTypenameconfig option.This is extending on
ResolversUnionTypesimplemented in #9069resolversNonOptionalTypenameadds non-optional__typenameto union members ofResolversUnionTypes, without affecting the union members' base interfaces.A common use case for non-optional
__typenameof union members is using it as the common field to work out the final schema type. This makes implementing the union's__resolveTypevery simple as we can use__typenameto decide which union member the resolved object is. Without this, we have to check the existence of field/s on the incoming object which could be verbose.For example, consider this schema:
type Query { book(id: ID!): BookPayload! } type Book { id: ID! isbn: String! } type BookResult { node: Book } type PayloadError { message: String! } union BookPayload = BookResult | PayloadError
With optional
__typename: We need to check existence of certain fields to resolve type in the union resolver:// Query/book.ts export const book = async () => { try { const book = await fetchBook() // 1. No `__typename` in resolver results... return { node: book } } catch (e) { return { message: 'Failed to fetch book' } } } // BookPayload.ts export const BookPayload = { __resolveType: parent => { // 2. ... means more checks in `__resolveType` if ('message' in parent) { return 'PayloadError' } return 'BookResult' } }
With non-optional
__typename: Resolvers declare the type. This which gives us better TypeScript support in resolvers and simplify__resolveTypeimplementation:// Query/book.ts export const book = async () => { try { const book = await fetchBook() // 1. `__typename` is declared in resolver results... return { __typename: 'BookResult', // 1a. this also types `node` for us 🎉 node: book } } catch (e) { return { __typename: 'PayloadError', message: 'Failed to fetch book' } } } // BookPayload.ts export const BookPayload = { __resolveType: parent => parent.__typename // 2. ... means a very simple check in `__resolveType` }
Using
resolversNonOptionalTypename: add it intotypescript-resolversplugin config:// codegen.ts const config: CodegenConfig = { schema: 'src/schema/**/*.graphql', generates: { 'src/schema/types.ts': { plugins: ['typescript', 'typescript-resolvers'], config: { resolversNonOptionalTypename: true // Or `resolversNonOptionalTypename: { unionMember: true }` } } } }
-
#9206
e56790104Thanks @eddeee888! - FixResolversUnionTypesbeing used inResolversParentTypesPreviously, objects with mappable fields are converted to Omit format that references its own type group or
ResolversTypesorResolversParentTypese.g.export type ResolversTypes = { Book: ResolverTypeWrapper<BookMapper> BookPayload: ResolversTypes['BookResult'] | ResolversTypes['StandardError'] // Note: `result` on the next line references `ResolversTypes["Book"]` BookResult: ResolverTypeWrapper<Omit<BookResult, 'result'> & { result?: Maybe<ResolversTypes['Book']> }> StandardError: ResolverTypeWrapper<StandardError> } export type ResolversParentTypes = { Book: BookMapper BookPayload: ResolversParentTypes['BookResult'] | ResolversParentTypes['StandardError'] // Note: `result` on the next line references `ResolversParentTypes["Book"]` BookResult: Omit<BookResult, 'result'> & { result?: Maybe<ResolversParentTypes['Book']> } StandardError: StandardError }
In #9069, we extracted resolver union types to its own group:
export type ResolversUnionTypes = { // Note: `result` on the next line references `ResolversTypes["Book"]` which is only correct for the `ResolversTypes` case BookPayload: (Omit<BookResult, 'result'> & { result?: Maybe<ResolversTypes['Book']> }) | StandardError } export type ResolversTypes = { Book: ResolverTypeWrapper<BookMapper> BookPayload: ResolverTypeWrapper<ResolversUnionTypes['BookPayload']> BookResult: ResolverTypeWrapper<Omit<BookResult, 'result'> & { result?: Maybe<ResolversTypes['Book']> }> StandardError: ResolverTypeWrapper<StandardError> } export type ResolversParentTypes = { Book: BookMapper BookPayload: ResolversUnionTypes['BookPayload'] BookResult: Omit<BookResult, 'result'> & { result?: Maybe<ResolversParentTypes['Book']> } StandardError: StandardError }
This change creates an extra
ResolversUnionParentTypesthat is referenced byResolversParentTypesto ensure backwards compatibility:export type ResolversUnionTypes = { BookPayload: (Omit<BookResult, 'result'> & { result?: Maybe<ResolversParentTypes['Book']> }) | StandardError } // ... and the reference is changed in ResolversParentTypes: export type ResolversParentTypes = { // ... other fields BookPayload: ResolversUnionParentTypes['BookPayload'] }
-
#9194
acb647e4eThanks @dstaley! - Don't emit import statements for unused fragments -
Updated dependencies [
b7dacb21f,f104619ac]:- @graphql-codegen/plugin-helpers@4.2.0
-
#9110
ba0610bbdThanks @gilgardosh! - Custom mappers with placeholder will apply omit -
#9069
4b49f6fbeThanks @eddeee888! - Extract union types to ResolversUnionTypes -
#8895
b343626c9Thanks @benkroeger! - Preserve .js extension when importDocumentNodeExternallyFrom and emitLegacyCommonJSImports is false
-
#8879
8206b268dThanks @renovate! - dependencies updates:- Updated dependency
tslib@~2.5.0↗︎ (from~2.4.0, independencies)
- Updated dependency
-
#8971
6b6fe3cbcThanks @n1ru4l! - Always inline referenced fragments within their document. This prevents issues with duplicated fragments or missing fragments. -
Updated dependencies [
8206b268d,a118c307a,a3309e63e]:- @graphql-codegen/plugin-helpers@4.1.0
- #8816
a98198524Thanks @charle692! - Fix issue where visitor-plugin-common emitted ESM imports for Operations when emitLegacyCommonJSImports is true
- #8771
ed87c782bThanks @renovate! - dependencies updates:- Updated dependency
@graphql-tools/utils@^9.0.0↗︎ (from^8.8.0, independencies)
- Updated dependency
- Updated dependencies [
ed87c782b,6c6b6f2df]:- @graphql-codegen/plugin-helpers@3.1.2
-
46f75304aThanks @saihaj! - fix the version of@graphql-codegen/plugin-helpers@3.1.1 -
Updated dependencies [
307a5d350]:- @graphql-codegen/plugin-helpers@3.1.1
- #8686
a6c2097f4Thanks @renovate! - dependencies updates:- Updated dependency
change-case-all@1.0.15↗︎ (from1.0.14, independencies)
- Updated dependency
- Updated dependencies [
a6c2097f4,f79a00e8a,c802a0c0b]:- @graphql-codegen/plugin-helpers@3.0.0
- #8664
62f655452Thanks @jdmoody! - Fix issue where selection set flattening uses the wrong parent type
- #8586
ef4c2c9c2Thanks @levrik! - Fix incompatibility between@oneOfinput types and declaration kind other thantype
-
#8525
63dc8f205Thanks @charlypoly! - removeDetailledError, not supported by Listr renderer -
Updated dependencies [
63dc8f205]:- @graphql-codegen/plugin-helpers@2.7.2
- #8498
a46b8d99cThanks @charlypoly! - Fragment masking$fragmentNameand$fragmentRefsare optionals
- #8432
1bd7f771cThanks @mvestergaard! - Remove extension from operations file import
-
#8189
b408f8238Thanks @n1ru4l! - Fix CommonJS TypeScript resolution withmoduleResolutionnode16ornodenext -
#8185
47d0a57e2Thanks @chrisands! - Fix emitLegacyCommonJSImports to being passed -
Updated dependencies [
b408f8238]:- @graphql-codegen/plugin-helpers@2.6.2
-
2cbcbb371: Add new flag to emit legacy common js imports. Default it will be
truethis way it ensure that generated code works with non-compliant bundlers.You can use the option in your config:
schema: 'schema.graphql' documents: - 'src/**/*.graphql' emitLegacyCommonJSImports: true
Alternative you can use the CLI to set this option:
$ codegen --config-file=config.yml --emit-legacy-common-js-imports
- Updated dependencies [2cbcbb371]
- @graphql-codegen/plugin-helpers@2.6.0
- 525ad580b: Revert breaking change for Next.js applications that are incapable of resolving an import with a
.jsextension.
-
68bb30e19: Attach
.jsextension to imports starting with either a.or/character. -
d84afec09: Support TypeScript ESM modules (
"module": "node16"and"moduleResolution": "node16").
- Updated dependencies [d84afec09]
- Updated dependencies [a4fe5006b]
- Updated dependencies [8e44df58b]
- @graphql-codegen/plugin-helpers@2.5.0
- aa1e6eafd: Add @Deprecated support for input
- a42fcbfe4: docs: Swapping rootValueType with directiveContextTypes for correctness
- 8b10f22be: Ensure falsy enum values are still mapped
-
d16bebacb: Update @graphql-tools/relay-operation-optimizer package;
- Previously that package used relay-compiler@12 which has graphql v15 as a peer dependency and it was causing peer dependency warnings if user installs a different version of
graphqlpackage. Now we forked and released v12 under a different name and removed version range forgraphqlinpeerDependenciesofrelay-compiler
- Previously that package used relay-compiler@12 which has graphql v15 as a peer dependency and it was causing peer dependency warnings if user installs a different version of
- c3d7b7226: support the
@oneOfdirective on input types.
- f1fb77bd4: feat: Add option to squash exactly similar fragment types
- 9a5f31cb6: New option
onlyEnumsfor Typescript
- 2966686e9: Generate $fragmentName for fragment subtypes for fragment masking
- 337fd4f77: WP: [typescript-resolvers] Add directiveContextTypes option
- 54718c039: Improve @Deprecated Enum Type developer experience
- 11d05e361: fix(resolvers): fix conflict between
typesPrefix: trueandenumPrefix: false
- fd55e2039: fix incorrect type generation when using the inlineFragmentTypes 'combine' option that resulted in generating masked fragment output.
- 1479233df: Add new
inlineFragmentTypesmode'mask', which allows generating masked fragment types.
- bef4376d5: fix: RequireFields generic making all other fields optional
- c8ef37ae0: fix(typescript-resolvers): Fix optional field types
- be7cb3a82: Performance work: resolvers plugins, documents loading
- Updated dependencies [754a33715]
- @graphql-codegen/plugin-helpers@2.4.0
- 6002feb3d: Fix exports in package.json files for react-native projects
- Updated dependencies [6002feb3d]
- @graphql-codegen/plugin-helpers@2.3.2
- a9f1f1594: Use maybeValue as default output for optionals on preResolveTypes: true
- 9ea6621ec: add missing ListType method parameters
- 97ddb487a: feat: GraphQL v16 compatibility
- Updated dependencies [97ddb487a]
- @graphql-codegen/plugin-helpers@2.3.0
- ad02cb9b8: Fixed an issue where ResolversParentTypes referenced non-existing fields of ResolversParentTypes when the corresponding type was a mapped enum.
- b9e85adae: feat(visitor-plugin-common): support custom scalar type from extensions
- 3c2c847be: Fix dedupleFragments option for typescript-react-query (and possibly others)
- Updated dependencies [7c60e5acc]
- @graphql-codegen/plugin-helpers@2.2.0
- 0b090e31a: Apply proper indentation to DirectiveArgs types
-
d6c2d4c09: Allow declaring Argument and InputType field mappings based on directive annotations.
WARNING: Using this option does only change the type definitions.
For actually ensuring that a type is correct at runtime you will have to use schema transforms (e.g. with @graphql-tools/utils mapSchema) that apply those rules! Otherwise, you might end up with a runtime type mismatch which could cause unnoticed bugs or runtime errors.
Please use this configuration option with care!
plugins: config: directiveArgumentAndInputFieldMappings: asNumber: number
directive @asNumber on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION input MyInput { id: ID! @asNumber } type User { id: ID! } type Query { user(id: ID! @asNumber): User }
Usage e.g. with
typescript-resolversconst Query: QueryResolvers = { user(_, args) { // args.id is of type 'number' } }
-
5086791ac: Allow overwriting the resolver type signature based on directive usages.
WARNING: Using this option does only change the generated type definitions.
For actually ensuring that a type is correct at runtime you will have to use schema transforms (e.g. with @graphql-tools/utils mapSchema) that apply those rules! Otherwise, you might end up with a runtime type mismatch which could cause unnoticed bugs or runtime errors.
Example configuration:
config: # This was possible before customResolverFn: ../resolver-types.ts#UnauthenticatedResolver # This is new directiveResolverMappings: authenticated: ../resolvers-types.ts#AuthenticatedResolver
Example mapping file (
resolver-types.ts):export type UnauthenticatedContext = { user: null } export type AuthenticatedContext = { user: { id: string } } export type UnauthenticatedResolver<TResult, TParent, _TContext, TArgs> = ( parent: TParent, args: TArgs, context: UnauthenticatedContext, info: GraphQLResolveInfo ) => Promise<TResult> | TResult export type AuthenticatedResolver<TResult, TParent, _TContext, TArgs> = ( parent: TParent, args: TArgs, context: AuthenticatedContext, info: GraphQLResolveInfo ) => Promise<TResult> | TResult
Example Schema:
directive @authenticated on FIELD_DEFINITION type Query { yee: String foo: String @authenticated }
- feeae1c66: Do not throw an error when trying to merge inline fragment usages.
- 6470e6cc9: fix(plugin-helpers): remove unnecessary import
- 263570e50: Don't generate duplicate imports for the same identifier
- Updated dependencies [6470e6cc9]
- Updated dependencies [35199dedf]
- @graphql-codegen/plugin-helpers@2.1.1
- aabeff181: Don't generate import statements for fragments declared in the file we're outputting to
- 290170262: add getOperationVariableName function to ClientSideBasePluginConfig class
- 440172cfe: support ESM
- 24185985a: bump graphql-tools package versions
- Updated dependencies [24185985a]
- Updated dependencies [39773f59b]
- Updated dependencies [440172cfe]
- @graphql-codegen/plugin-helpers@2.1.0
-
d80efdec4: Change
preResolveTypesdefault to betruefor more readable types -
b0cb13df4: Update to latest
graphql-toolsandgraphql-configversion.‼️ ‼️ ‼️ Please note‼️ ‼️ ‼️ :This is a breaking change since Node 10 is no longer supported in
graphql-tools, and also no longer supported for Codegen packages.
-
d80efdec4: Add option
inlineFragmentTypesfor deep inlining fragment types within operation types. ThisinlineFragmentTypesis set toinlineby default (Previous behaviour iscombine).This behavior is the better default for users that only use Fragments for building operations and then want to have access to all the data via the operation type (instead of accessing slices of the data via fragments).
-
Updated dependencies [b0cb13df4]
- @graphql-codegen/plugin-helpers@2.0.0
- 9005cc17: add
allowEnumStringTypesoption for allowing string literals as valid return types from resolvers in addition to enum values._
- df19a4ed: Allow multiple
{T}instances in defaultMapper - Updated dependencies [470336a1]
- @graphql-codegen/plugin-helpers@1.18.8
- 6762aff5: Fix for array types with @skip @include directives
- 6aaecf1c: Fix issues with missing sub-fragments when skipTypename: true
- cf1e5abc: Introduce new feature for removing duplicated fragments
- 8da7dff6: Skip typechecking on generated values by casting to unknown
- dfd25caf: chore(deps): bump graphql-tools versions
- Updated dependencies [dfd25caf]
- @graphql-codegen/plugin-helpers@1.18.7
- f0b5ea53: Add entireFieldWrapperValue configuration option, to wrap arrays
- 097bea2f: Added new configuration settings for scalars:
strictScalarsanddefaultScalarType
- d9212aa0: fix(visitor-plugin-common): guard for a runtime type error
- Updated dependencies [d9212aa0]
- @graphql-codegen/plugin-helpers@1.18.5
- 23862e7e: fix(naming-convention): revert and pin change-case-all dependency for workaround #3256
- Updated dependencies [23862e7e]
- @graphql-codegen/plugin-helpers@1.18.4
- d4942d04: NEW CONFIG (
onlyResolveTypeForInterfaces): Allow to generate only __resolveType for interfaces
- e947f8e3: Allow to have declarationKind of type: class, interface: interface
- 29b75b1e: enhance(docs): improve docs for naming convention
- 1f6f3db6: Fix for @skip @include directives upon arrays
- 29b75b1e: enhance(namingConvention): use change-case-all instead of individual packages for naming convention
- Updated dependencies [29b75b1e]
- @graphql-codegen/plugin-helpers@1.18.3
- 5749cb8a: chore: fix type-level incompatibilities of the
avoidOptionals - 5a12fe58: fix type error on parsing enums
- ca66569f: Fix issues with undefined calls for str.replace
- 63be0f40: Fix issues with empty interfaces causing syntax issues
- 190482a1: add support for fragment variables
- 4444348d: Correctly escape enum values defined in the GraphQLSchema object
- 142b32b3: Better support for @skip/@include directives with complex selection sets
- 42213fa0: Strip trailing whitespace from some output
- bd4bf7cf: feat(visitor-plugin-common): add ignoreEnumValuesFromSchema to ignore enum values from GraphQLSchema
- 64293437: Support for input lists coercion
- fd5843a7: Fixed a bug where some import namespacing is missed when generating resolver types.
- d75051f5: generate correct types for fragments with an interface type condition that are spread on an interface field.
- 8356f8a2: Extended behaviour to allow support in
internalResolversPrefixflag for resolvers plugin
- 1183d173: Bump all packages to resolve issues with shared dependencies
- Updated dependencies [1183d173]
- @graphql-codegen/plugin-helpers@1.18.2
- 99819bf1: Improve DocumentNode optimization for plugins that generate it
- c3b59e81: Extract buildMapperImport to external function
- faa13973: Fixed a bug in
parseMapperthat were preventing to use mappers with complex type usages
- 612e5e52: remove broken isTypeOf call for expanding fragments with flattenGeneratedTypes = true
- 9f2a4e2f: Expose
_hasRequiredVariablestobuildOperationin order to allow better type-safety for plugins that deals withvariables - 0f35e775: Fix issues with incorrect naming of operation and variables when used with typesSuffix
- Updated dependencies [eaf45d1f]
- @graphql-codegen/plugin-helpers@1.18.1
- 92d8f876: Fixed unquoted numeric enum identifiers
- d2cde3d5: fixed isTypeOf resolvers signature
- 89a6aa80: Fixes issues with typesSuffix and arguments type name
- f603b8f8: Support unnamed queries in operation visitors
- Updated dependencies [da8bdd17]
- @graphql-codegen/plugin-helpers@1.17.9
- 07f9b1b2: Fix a bug caused numeric enum values defined in the GraphQLSchema to be printed incorrectly
- 35f67120: bugfix: allow to specify mappers for GraphQL
interfaceand override the default behaviour.
- 1d7c6432: Bump all packages to allow "^" in deps and fix compatibility issues
- 1d7c6432: Bump versions of @graphql-tools/ packages to fix issues with loading schemas and SDL comments
- Updated dependencies [1d7c6432]
- Updated dependencies [1d7c6432]
- @graphql-codegen/plugin-helpers@1.17.8
- 4266a15f: Allow getDocumentNodeSignature to control the entire generation flow of the typed documents
- ee2b01a3: Fixes for issues with publish command
- 6cb9c96d: Fixes issues with previous release
- bccfd28c: Allow to set
gqlImportto a cleangqlstring and skip import generating
- ce3a5798: Publish minor version to include fixes for client-side-base-visitor, required to v2 of ts-react-apollo plugin (for unified apollo import)