@graphql-codegen/typescript-resolvers
Changelog for @graphql-codegen/typescript-resolvers: every release with its changes and the pull requests behind them.
6.1.0
Minor Changes
- #10866
959915fThanks @eddeee888! - dependencies updates:- Updated dependency
@graphql-tools/utils@^11.2.0↗︎ (from^11.0.0, independencies) - Updated dependency
graphql@^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0↗︎ (from^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0, inpeerDependencies)
- Updated dependency
Patch Changes
- Updated dependencies
[
959915f,959915f,959915f]:- @graphql-codegen/plugin-helpers@7.1.0
- @graphql-codegen/typescript@6.1.0
- @graphql-codegen/visitor-plugin-common@7.2.0
6.0.2
Patch Changes
- #10849
55a4742Thanks @eddeee888! - dependencies updates:- Updated dependency
@graphql-codegen/plugin-helpers@workspace:^↗︎ (from^7.0.1, independencies) - Updated dependency
@graphql-codegen/typescript@workspace:^↗︎ (from^6.0.0, independencies) - Updated dependency
@graphql-codegen/visitor-plugin-common@workspace:^↗︎ (from^7.0.0, independencies)
- Updated dependency
- Updated dependencies
[
55a4742,55a4742]:- @graphql-codegen/typescript@6.0.2
- @graphql-codegen/visitor-plugin-common@7.0.3
6.0.1
Patch Changes
-
#10797
6ed420aThanks @eddeee888! - Fix FederationTypes not having typesPrefix and typesSuffix applied -
Updated dependencies [
6ed420a]:- @graphql-codegen/plugin-helpers@7.0.1
6.0.0
Major Changes
-
#10496
afaace6Thanks @eddeee888! - BREAKING CHANGE: visitors’ config option are moved based on their use case- addTypename/skipTypename: is only a types-visitor concern. This is moved to types-visitor from base-visitor
- nonOptionalTypename: is a documents-visitor and types-visitor concern. Moved from base-visitor there
- extractAllFieldsToTypes: is a documents-visitor concern. Moved from base-visitor there
- enumPrefix and enumSuffix: need to be in base-visitor as all 3 types of visitors need this to correctly sync the enum type names. This is moved to base visitor
- ignoreEnumValuesFromSchema: is a documents-visitor and types-visitor concern. Moved from base-visitor there.
- globalNamespace: is a documents-visitor concern. Moved from base-visitor there
Refactors
- documents-visitor no longer extends types-visitor option types as they have two distinct usages now. The types now extend base-visitor types. This is now consistent with documents-visitor extending base-visitor
- Classes now handle config parsing and types at the same level e.g. if typescript-operations plugin parses configOne, then the types for configOne must be in that class, rather than in base-documents-visitor
Note: These visitors are rolled up into one type for simplicity
- base-visitor: includes
base-visitor - documents-visitor: includes
base-documents-visitorandtypescript-operationsvisitor - types-visitor: includes
base-types-visitorandtypescriptvisitor - resolvers-visitor: includes
base-resolvers-visitorandtypescript-resolversvisitor
-
#10496
afaace6Thanks @eddeee888! - BREAKING CHANGE: makeunknowninstead ofanythe default custom scalar type -
#10496
afaace6Thanks @eddeee888! - BREAKING CHANGE: Update deps to latest, some only support ESMNode 20 support is dropped in this release. Node 22 comes with
require()support for ESM, which means it’s easier to integrate ES modules into applications. Therefore, it is safe to start using ESM-only packages.If you are a user, please upgrade to Node 22. If you are a lib maintainer and see ESM vs CJS issues when running Jest tests, try using Vitest.
-
#10496
afaace6Thanks @eddeee888! - BREAKING CHANGE: Drop Node 20 support
Patch Changes
-
#10496
afaace6Thanks @eddeee888! - dependencies updates:- Updated dependency
auto-bind@^5.0.0↗︎ (from~4.0.0, independencies)
- Updated dependency
-
#10496
afaace6Thanks @eddeee888! - dependencies updates:- Updated dependency
auto-bind@^5.0.0↗︎ (from~4.0.0, independencies)
- Updated dependency
-
#10496
afaace6Thanks @eddeee888! - Fix namingConvention not being applied consistently -
#10496
afaace6Thanks @eddeee888! - Abstract how enum imports are generated into visitor-plugin-common package -
Updated dependencies [
afaace6,afaace6,afaace6,afaace6,afaace6,afaace6,afaace6,afaace6,afaace6,afaace6,afaace6,afaace6,afaace6,afaace6,afaace6,afaace6,afaace6,afaace6,afaace6,afaace6,afaace6,afaace6,afaace6,afaace6,afaace6,afaace6,afaace6,afaace6,afaace6]:- @graphql-codegen/plugin-helpers@7.0.0
- @graphql-codegen/typescript@6.0.0
- @graphql-codegen/visitor-plugin-common@7.0.0
5.1.8
Patch Changes
- #10103
9a66574Thanks @renovate! - dependencies updates:- Updated dependency
tslib@^2.8.0↗︎ (from~2.6.0, independencies)
- Updated dependency
- Updated dependencies
[
9a66574,9a66574,9a66574,e65d303]:- @graphql-codegen/plugin-helpers@6.3.0
- @graphql-codegen/typescript@5.0.10
- @graphql-codegen/visitor-plugin-common@6.3.0
5.1.7
Patch Changes
- #10619
cdf5dc5Thanks @ardatan! - dependencies updates:- Updated dependency
@graphql-codegen/visitor-plugin-common@^6.2.3↗︎ (from6.2.3, independencies) - Updated dependency
@graphql-tools/utils@^11.0.0↗︎ (from^10.0.0, independencies)
- Updated dependency
- Updated dependencies
[
cdf5dc5,cdf5dc5,cdf5dc5]:- @graphql-codegen/plugin-helpers@6.1.1
- @graphql-codegen/typescript@5.0.9
- @graphql-codegen/visitor-plugin-common@6.2.4
5.1.6
Patch Changes
- Updated dependencies
[
6038634]:- @graphql-codegen/visitor-plugin-common@6.2.3
- @graphql-codegen/typescript@5.0.8
5.1.5
Patch Changes
- Updated dependencies
[
f588d91]:- @graphql-codegen/visitor-plugin-common@6.2.2
- @graphql-codegen/typescript@5.0.7
5.1.4
Patch Changes
- Updated dependencies
[
b995ed1]:- @graphql-codegen/visitor-plugin-common@6.2.1
- @graphql-codegen/typescript@5.0.6
5.1.3
Patch Changes
- Updated dependencies
[
f821e8a,9e70bcb]:- @graphql-codegen/visitor-plugin-common@6.2.0
- @graphql-codegen/plugin-helpers@6.1.0
- @graphql-codegen/typescript@5.0.5
5.1.2
Patch Changes
- Updated dependencies
[
51a1a72]:- @graphql-codegen/visitor-plugin-common@6.1.2
- @graphql-codegen/typescript@5.0.4
5.1.1
Patch Changes
- Updated dependencies
[
6715330]:- @graphql-codegen/visitor-plugin-common@6.1.1
- @graphql-codegen/typescript@5.0.3
5.1.0
Minor Changes
- #10449
8258f1fThanks @eddeee888! - AddaddInterfaceFieldResolverTypesoption to support custom Interface resolver inheritance behaviour (such as the one enabled by makeExecutableSchema’s inheritResolversFromInterfaces)
Patch Changes
- Updated dependencies
[
8258f1f]:- @graphql-codegen/visitor-plugin-common@6.1.0
- @graphql-codegen/typescript@5.0.2
5.0.1
Patch Changes
- Updated dependencies
[
accdab6]:- @graphql-codegen/visitor-plugin-common@6.0.1
- @graphql-codegen/typescript@5.0.1
5.0.0
Major Changes
-
#10218
140298aThanks @eddeee888! - BREAKING CHANGES: Do not generate __isTypeOf for non-implementing types or non-union members -
#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. Interface normal resolvers are not generated by default. UseaddInterfaceFieldResolverTypesoption released in@graphql-codegen/typescript-resolvers@5.1.0to support custom Interface resolver inheritance behaviour (such as the one enabled by makeExecutableSchema’s inheritResolversFromInterfaces) 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! - 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
Minor Changes
- #10218
140298aThanks @eddeee888! - Report to meta user defined objects whether they have isTypeOf resolver
Patch Changes
-
#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,140298a,140298a,140298a,140298a,140298a]:- @graphql-codegen/visitor-plugin-common@6.0.0
- @graphql-codegen/plugin-helpers@6.0.0
- @graphql-codegen/typescript@5.0.0
4.5.2
Patch Changes
- #10419
2fc3869Thanks @chdanielmueller! - Fix enum resolver for partially mapped enumValues
4.5.1
Patch Changes
- #10330
c5efba3Thanks @jnoordsij! - Make graphql-sock optional peerDep
4.5.0
Minor Changes
- #10315
f6909d1Thanks @eddeee888! - Implement semanticNonNull custom directive
Patch Changes
- Updated dependencies
[
f6909d1]:- @graphql-codegen/visitor-plugin-common@5.8.0
- @graphql-codegen/typescript@4.1.6
4.4.4
Patch Changes
- Updated dependencies
[
d8566c0]:- @graphql-codegen/visitor-plugin-common@5.7.1
- @graphql-codegen/typescript@4.1.5
4.4.3
Patch Changes
- Updated dependencies
[
6d7c1d7]:- @graphql-codegen/visitor-plugin-common@5.7.0
- @graphql-codegen/typescript@4.1.4
4.4.2
Patch Changes
-
#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. -
Updated dependencies [
60dd72f]:- @graphql-codegen/visitor-plugin-common@5.6.1
- @graphql-codegen/typescript@4.1.3
4.4.1
Patch Changes
-
#10187
1617e3cThanks @gilgardosh! - Fix: type naming for imported enums -
Updated dependencies [
1617e3c,fa64fbf]:- @graphql-codegen/visitor-plugin-common@5.6.0
- @graphql-codegen/typescript@4.1.2
4.4.0
Minor Changes
-
#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.
Patch Changes
- Updated dependencies
[
55a1e9e,a235051]:- @graphql-codegen/visitor-plugin-common@5.5.0
- @graphql-codegen/plugin-helpers@5.1.0
- @graphql-codegen/typescript@4.1.1
4.3.0
Minor Changes
-
#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.
Patch Changes
- Updated dependencies
[
3f4f546]:- @graphql-codegen/visitor-plugin-common@5.4.0
- @graphql-codegen/typescript@4.1.0
4.2.1
Patch Changes
-
#10014
79fee3cThanks @eddeee888! - Fix object types with fields being abstract types not pointing to resolver types correctly -
Updated dependencies [
79fee3c]:- @graphql-codegen/visitor-plugin-common@5.3.1
- @graphql-codegen/typescript@4.0.9
4.2.0
Minor Changes
- #10007
808ada5Thanks @eddeee888! - Add generated resolvers map type name to typescript-resolvers plugin meta
Patch Changes
- Updated dependencies
[
808ada5,14ce39e]:- @graphql-codegen/visitor-plugin-common@5.3.0
- @graphql-codegen/typescript@4.0.8
4.1.0
Minor Changes
- #9961
dfc5310Thanks @eddeee888! - Update typescript-resolvers to report generated resolver types in the run to meta field in the output
Patch Changes
-
#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,156cc2b,dfc5310,b49457b]:- @graphql-codegen/plugin-helpers@5.0.4
- @graphql-codegen/visitor-plugin-common@5.2.0
- @graphql-codegen/typescript@4.0.7
4.0.6
Patch Changes
- Updated dependencies
[
920b443,ed9c205]:- @graphql-codegen/visitor-plugin-common@5.1.0
- @graphql-codegen/typescript@4.0.6
4.0.5
Patch Changes
- Updated dependencies
[
53f270a]:- @graphql-codegen/visitor-plugin-common@5.0.0
- @graphql-codegen/typescript@4.0.5
4.0.4
Patch Changes
-
Updated dependencies [
4e69568]:- @graphql-codegen/visitor-plugin-common@4.1.2
- @graphql-codegen/typescript@4.0.4
- @graphql-codegen/plugin-helpers@5.0.3
4.0.3
Patch Changes
-
#9673
7718a8113Thanks @maclockard! - Respect avoidOptionals when all arguments are optional -
Updated dependencies [
7718a8113]:- @graphql-codegen/visitor-plugin-common@4.1.1
- @graphql-codegen/typescript@4.0.3
4.0.2
Patch Changes
- #9811
d8364e045Thanks @saihaj! - dependencies updates:- Updated dependency
tslib@~2.6.0↗︎ (from~2.5.0, independencies)
- Updated dependency
- Updated dependencies
[
d8364e045,d8364e045,d8364e045,d8364e045,d8364e045]:- @graphql-codegen/plugin-helpers@5.0.2
- @graphql-codegen/typescript@4.0.2
- @graphql-codegen/visitor-plugin-common@4.1.0
4.0.1
Patch Changes
-
#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. -
Updated dependencies [
2276708d0]:- @graphql-codegen/visitor-plugin-common@4.0.1
- @graphql-codegen/typescript@4.0.1
4.0.0
Major Changes
-
#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
Minor Changes
-
#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. 2.resolversNonOptionalTypenamealso affectsResolversInterfaceTypesUsing 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... }
Patch Changes
- #9449
4d9ea1a5aThanks @n1ru4l! - dependencies updates:- Updated dependency
@graphql-tools/utils@^10.0.0↗︎ (from^9.0.0, independencies)
- Updated dependency
- Updated dependencies
[
4d9ea1a5a,4d9ea1a5a,f46803a8c,3848a2b73,ba84a3a27,63827fabe,50471e651,5aa95aa96,ca02ad172,e1dc75f3c,bb66c2a31,5950f5a68,5aa95aa96]:- @graphql-codegen/plugin-helpers@5.0.0
- @graphql-codegen/visitor-plugin-common@4.0.0
- @graphql-codegen/typescript@4.0.0
3.2.1
Patch Changes
-
#9231
402cb8ac0Thanks @eddeee888! - Implement resolversNonOptionalTypename for mapper cases -
Updated dependencies [
386cf9044,402cb8ac0]:- @graphql-codegen/visitor-plugin-common@3.1.1
- @graphql-codegen/typescript@3.0.4
3.2.0
Minor Changes
-
#9146
9f4d9c5a4Thanks @eddeee888! - [typescript-resolvers] AddresolversNonOptionalTypenameconfig option.This is extending on
ResolversUnionTypesimplemented in https://github.com/dotansimha/graphql-code-generator/pull/9069resolversNonOptionalTypenameadds non-optional__typenameto union members ofResolversUnionTypes, without affecting the union members’ base intefaces.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 | PayloadErrorWith 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: any) { 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: any) { 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 }` } } } }
Patch Changes
-
#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 https://github.com/dotansimha/graphql-code-generator/pull/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'] } -
f104619acThanks @saihaj! - Resolve issue with nesting fields in@providesdirective being prevented -
Updated dependencies [
e56790104,b7dacb21f,f104619ac,92d86b009,acb647e4e,9f4d9c5a4]:- @graphql-codegen/visitor-plugin-common@3.1.0
- @graphql-codegen/plugin-helpers@4.2.0
- @graphql-codegen/typescript@3.0.3
3.1.1
Patch Changes
-
#9110
ba0610bbdThanks @gilgardosh! - Custom mappers with placeholder will apply omit -
#9069
4b49f6fbeThanks @eddeee888! - Extract union types to ResolversUnionTypes -
Updated dependencies [
ba0610bbd,4b49f6fbe,b343626c9]:- @graphql-codegen/visitor-plugin-common@3.0.2
- @graphql-codegen/typescript@3.0.2
3.1.0
Minor Changes
- #8853
b13aa7449Thanks @KGAdamCook! - Updated customResolveInfo to use the correct importType for external imports
Patch Changes
- #8879
8206b268dThanks @renovate! - dependencies updates:- Updated dependency
tslib@~2.5.0↗︎ (from~2.4.0, independencies)
- Updated dependency
- Updated dependencies
[
8206b268d,8206b268d,8206b268d,a118c307a,6b6fe3cbc,a3309e63e]:- @graphql-codegen/plugin-helpers@4.1.0
- @graphql-codegen/typescript@3.0.1
- @graphql-codegen/visitor-plugin-common@3.0.1
3.0.0
Major Changes
Patch Changes
-
Updated dependencies [
fc79b65d4,fd0b0c813]:- @graphql-codegen/visitor-plugin-common@3.0.0
- @graphql-codegen/plugin-helpers@4.0.0
- @graphql-codegen/typescript@3.0.0
2.7.13
Patch Changes
- Updated dependencies
[
a98198524]:- @graphql-codegen/visitor-plugin-common@2.13.8
- @graphql-codegen/typescript@2.8.8
2.7.12
Patch Changes
- Updated dependencies
[
eb454d06c]:- @graphql-codegen/visitor-plugin-common@2.13.7
- @graphql-codegen/typescript@2.8.7
2.7.11
Patch Changes
- #8771
ed87c782bThanks @renovate! - dependencies updates:- Updated dependency
@graphql-tools/utils@^9.0.0↗︎ (from^8.8.0, independencies)
- Updated dependency
- Updated dependencies
[
ed87c782b,ed87c782b,6c6b6f2df]:- @graphql-codegen/plugin-helpers@3.1.2
- @graphql-codegen/visitor-plugin-common@2.13.6
- @graphql-codegen/typescript@2.8.6
2.7.10
Patch Changes
-
46f75304aThanks @saihaj! - fix the version of@graphql-codegen/plugin-helpers@3.1.1 -
Updated dependencies [
307a5d350,46f75304a]:- @graphql-codegen/plugin-helpers@3.1.1
- @graphql-codegen/visitor-plugin-common@2.13.5
- @graphql-codegen/typescript@2.8.5
2.7.9
Patch Changes
- Updated dependencies
[
a6c2097f4,a6c2097f4,f79a00e8a,c802a0c0b]:- @graphql-codegen/plugin-helpers@3.0.0
- @graphql-codegen/visitor-plugin-common@2.13.4
- @graphql-codegen/typescript@2.8.4
2.7.8
Patch Changes
- Updated dependencies
[
62f655452]:- @graphql-codegen/visitor-plugin-common@2.13.3
- @graphql-codegen/typescript@2.8.3
2.7.7
Patch Changes
- Updated dependencies
[
ef4c2c9c2]:- @graphql-codegen/visitor-plugin-common@2.13.2
- @graphql-codegen/typescript@2.8.2
2.7.6
Patch Changes
- Updated dependencies
[
63dc8f205]:- @graphql-codegen/visitor-plugin-common@2.13.1
- @graphql-codegen/plugin-helpers@2.7.2
- @graphql-codegen/typescript@2.8.1
2.7.5
Patch Changes
- Updated dependencies
[
a46b8d99c]:- @graphql-codegen/visitor-plugin-common@2.13.0
- @graphql-codegen/typescript@2.7.5
2.7.4
Patch Changes
- Updated dependencies
[
1bd7f771c]:- @graphql-codegen/visitor-plugin-common@2.12.2
- @graphql-codegen/typescript@2.7.4
2.7.3
Patch Changes
-
#8189
b408f8238Thanks @n1ru4l! - Fix CommonJS TypeScript resolution withmoduleResolutionnode16ornodenext -
Updated dependencies [
b408f8238,47d0a57e2]:- @graphql-codegen/visitor-plugin-common@2.12.1
- @graphql-codegen/typescript@2.7.3
- @graphql-codegen/plugin-helpers@2.6.2
2.7.2
Patch Changes
- Updated dependencies [2cbcbb371]
- @graphql-codegen/visitor-plugin-common@2.12.0
- @graphql-codegen/plugin-helpers@2.6.0
- @graphql-codegen/typescript@2.7.2
2.7.1
Patch Changes
- 525ad580b: Revert breaking change for Next.js applications that are incapable of resolving an
import with a
.jsextension. - Updated dependencies [525ad580b]
- @graphql-codegen/visitor-plugin-common@2.11.1
- @graphql-codegen/typescript@2.7.1
2.7.0
Minor Changes
-
d84afec09: Support TypeScript ESM modules (
"module": "node16"and"moduleResolution": "node16").
Patch Changes
- Updated dependencies [68bb30e19]
- Updated dependencies [d84afec09]
- Updated dependencies [a4fe5006b]
- Updated dependencies [8e44df58b]
- @graphql-codegen/visitor-plugin-common@2.11.0
- @graphql-codegen/typescript@2.7.0
- @graphql-codegen/plugin-helpers@2.5.0
2.6.7
Patch Changes
- Updated dependencies [aa1e6eafd]
- Updated dependencies [a42fcbfe4]
- Updated dependencies [8b10f22be]
- @graphql-codegen/typescript@2.6.0
- @graphql-codegen/visitor-plugin-common@2.10.0
2.6.6
Patch Changes
- Updated dependencies [d16bebacb]
- @graphql-codegen/visitor-plugin-common@2.9.1
- @graphql-codegen/typescript@2.5.1
2.6.5
Patch Changes
- Updated dependencies [c3d7b7226]
- @graphql-codegen/visitor-plugin-common@2.9.0
- @graphql-codegen/typescript@2.5.0
2.6.4
Patch Changes
- Updated dependencies [f1fb77bd4]
- @graphql-codegen/visitor-plugin-common@2.8.0
- @graphql-codegen/typescript@2.4.11
2.6.3
Patch Changes
- Updated dependencies [9a5f31cb6]
- @graphql-codegen/typescript@2.4.10
- @graphql-codegen/visitor-plugin-common@2.7.6
2.6.2
Patch Changes
- Updated dependencies [2966686e9]
- @graphql-codegen/visitor-plugin-common@2.7.5
- @graphql-codegen/typescript@2.4.9
2.6.1
Patch Changes
- 337fd4f77: WP: [typescript-resolvers] Add directiveContextTypes option
- Updated dependencies [337fd4f77]
- @graphql-codegen/visitor-plugin-common@2.7.4
- @graphql-codegen/typescript@2.4.8
2.6.0
Minor Changes
- a3b348cd7: feat(resolvers): add factory signature to ‘selectionSet’ param of stitching resolvers
2.5.4
Patch Changes
- Updated dependencies [54718c039]
- @graphql-codegen/typescript@2.4.7
- @graphql-codegen/visitor-plugin-common@2.7.3
2.5.3
Patch Changes
- 1f5aaf097: Fix #7566 external resolver name export for directiveResolverMappings
- Updated dependencies [11d05e361]
- @graphql-codegen/visitor-plugin-common@2.7.2
- @graphql-codegen/typescript@2.4.6
2.5.2
Patch Changes
- Updated dependencies [fd55e2039]
- @graphql-codegen/visitor-plugin-common@2.7.1
- @graphql-codegen/typescript@2.4.5
2.5.1
Patch Changes
- Updated dependencies [1479233df]
- @graphql-codegen/visitor-plugin-common@2.7.0
- @graphql-codegen/typescript@2.4.4
2.5.0
Minor Changes
- bef4376d5: fix: RequireFields generic making all other fields optional
Patch Changes
- c8ef37ae0: fix(typescript-resolvers): Fix optional field types
- Updated dependencies [c8ef37ae0]
- Updated dependencies [754a33715]
- Updated dependencies [bef4376d5]
- Updated dependencies [be7cb3a82]
- @graphql-codegen/visitor-plugin-common@2.6.0
- @graphql-codegen/plugin-helpers@2.4.0
- @graphql-codegen/typescript@2.4.3
2.4.3
Patch Changes
- 6002feb3d: Fix exports in package.json files for react-native projects
- Updated dependencies [6002feb3d]
- @graphql-codegen/visitor-plugin-common@2.5.2
- @graphql-codegen/typescript@2.4.2
- @graphql-codegen/plugin-helpers@2.3.2
2.4.2
Patch Changes
- Updated dependencies [a9f1f1594]
- Updated dependencies [9ea6621ec]
- @graphql-codegen/visitor-plugin-common@2.5.1
- @graphql-codegen/typescript@2.4.1
2.4.1
Patch Changes
- 3d57ec666: loosen return type of SubscriptionSubscribeFn from
PromiseOrValue<AsyncIterator>toPromiseOrValue<AsyncIterable>. This fixes type conflicts with libraries such asix/asynciterableand is whatgraphql-jsexpects.
2.4.0
Minor Changes
- 97ddb487a: feat: GraphQL v16 compatibility
Patch Changes
- Updated dependencies [97ddb487a]
- @graphql-codegen/visitor-plugin-common@2.5.0
- @graphql-codegen/typescript@2.3.0
- @graphql-codegen/plugin-helpers@2.3.0
2.3.2
Patch Changes
- Updated dependencies [ad02cb9b8]
- @graphql-codegen/visitor-plugin-common@2.4.0
- @graphql-codegen/typescript@2.2.4
2.3.1
Patch Changes
- Updated dependencies [b9e85adae]
- Updated dependencies [7c60e5acc]
- Updated dependencies [3c2c847be]
- @graphql-codegen/visitor-plugin-common@2.3.0
- @graphql-codegen/plugin-helpers@2.2.0
- @graphql-codegen/typescript@2.2.3
2.3.0
Minor Changes
- 46b38d9c1: Add makeResolverTypeCallable property to config which allows a resolver function to be called
2.2.1
Patch Changes
- Updated dependencies [0b090e31a]
- @graphql-codegen/visitor-plugin-common@2.2.1
- @graphql-codegen/typescript@2.2.2
2.2.0
Minor Changes
-
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#AuthenticatedResolverExample 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> | TResultExample Schema:
directive @authenticated on FIELD_DEFINITION type Query { yee: String foo: String @authenticated }
Patch Changes
- Updated dependencies [d6c2d4c09]
- Updated dependencies [feeae1c66]
- Updated dependencies [8261e4161]
- Updated dependencies [5086791ac]
- @graphql-codegen/visitor-plugin-common@2.2.0
- @graphql-codegen/typescript@2.2.0
2.1.2
Patch Changes
- Updated dependencies [6470e6cc9]
- Updated dependencies [263570e50]
- Updated dependencies [35199dedf]
- @graphql-codegen/visitor-plugin-common@2.1.2
- @graphql-codegen/plugin-helpers@2.1.1
- @graphql-codegen/typescript@2.1.2
2.1.1
Patch Changes
- Updated dependencies [aabeff181]
- @graphql-codegen/visitor-plugin-common@2.1.1
- @graphql-codegen/typescript@2.1.1
2.1.0
Minor Changes
- 39773f59b: enhance(plugins): use getDocumentNodeFromSchema and other utilities from @graphql-tools/utils
- 440172cfe: support ESM
Patch Changes
- 24185985a: bump graphql-tools package versions
- 440172cfe: export config types
- Updated dependencies [290170262]
- Updated dependencies [24185985a]
- Updated dependencies [39773f59b]
- Updated dependencies [440172cfe]
- @graphql-codegen/visitor-plugin-common@2.1.0
- @graphql-codegen/plugin-helpers@2.1.0
- @graphql-codegen/typescript@2.1.0
2.0.0
Major Changes
-
d80efdec4: Set
noSchemaStitching: trueby default.If you need the resolvers signature to support schema-stitching, please add to your config:
noSchemaStitching: false -
d80efdec4: Remove deprecated
IDirectiveResolversandIResolverssignaturesPlease use
DirectiveResolversandResolverstypes instead. -
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.
Patch Changes
- Updated dependencies [d80efdec4]
- Updated dependencies [d80efdec4]
- Updated dependencies [b0cb13df4]
- @graphql-codegen/visitor-plugin-common@2.0.0
- @graphql-codegen/typescript@2.0.0
- @graphql-codegen/plugin-helpers@2.0.0
1.20.0
Minor Changes
- 8e4d5826: Add a new type for StitchResolver without selectionSet
- 9005cc17: add
allowEnumStringTypesoption for allowing string literals as valid return types from resolvers in addition to enum values._
Patch Changes
- df19a4ed: Allow multiple
{T}instances in defaultMapper - Updated dependencies [df19a4ed]
- Updated dependencies [470336a1]
- Updated dependencies [9005cc17]
- @graphql-codegen/visitor-plugin-common@1.22.0
- @graphql-codegen/plugin-helpers@1.18.8
- @graphql-codegen/typescript@1.23.0
1.19.5
Patch Changes
- Updated dependencies [6762aff5]
- @graphql-codegen/visitor-plugin-common@1.21.3
- @graphql-codegen/typescript@1.22.4
1.19.4
Patch Changes
- Updated dependencies [6aaecf1c]
- @graphql-codegen/visitor-plugin-common@1.21.2
- @graphql-codegen/typescript@1.22.3
1.19.3
Patch Changes
- Updated dependencies [cf1e5abc]
- @graphql-codegen/visitor-plugin-common@1.21.1
- @graphql-codegen/typescript@1.22.2
1.19.2
Patch Changes
- dfd25caf: chore(deps): bump graphql-tools versions
- Updated dependencies [dfd25caf]
- Updated dependencies [8da7dff6]
- @graphql-codegen/visitor-plugin-common@1.21.0
- @graphql-codegen/plugin-helpers@1.18.7
- @graphql-codegen/typescript@1.22.1
1.19.1
Patch Changes
- d9212aa0: fix(visitor-plugin-common): guard for a runtime type error
- Updated dependencies [d9212aa0]
- Updated dependencies [f0b5ea53]
- Updated dependencies [097bea2f]
- @graphql-codegen/visitor-plugin-common@1.20.0
- @graphql-codegen/typescript@1.22.0
- @graphql-codegen/plugin-helpers@1.18.5
1.19.0
Minor Changes
- d4942d04: NEW CONFIG (
onlyResolveTypeForInterfaces): Allow to generate only __resolveType for interfaces
Patch Changes
- 29b75b1e: enhance(namingConvention): use change-case-all instead of individual packages for naming convention
- Updated dependencies [e947f8e3]
- Updated dependencies [29b75b1e]
- Updated dependencies [d4942d04]
- Updated dependencies [1f6f3db6]
- Updated dependencies [29b75b1e]
- @graphql-codegen/visitor-plugin-common@1.19.0
- @graphql-codegen/typescript@1.21.1
- @graphql-codegen/plugin-helpers@1.18.3
1.18.2
Patch Changes
- 5749cb8a: chore: fix type-level incompatibilities of the
avoidOptionals - Updated dependencies [34b8087e]
- Updated dependencies [5749cb8a]
- Updated dependencies [5a12fe58]
- @graphql-codegen/typescript@1.21.0
- @graphql-codegen/visitor-plugin-common@1.18.3
1.18.1
Patch Changes
- fd5843a7: Fixed a bug where some import namespacing is missed when generating resolver types.
- Updated dependencies [64293437]
- Updated dependencies [fd5843a7]
- Updated dependencies [d75051f5]
- @graphql-codegen/visitor-plugin-common@1.17.22
1.18.0
Minor Changes
- 8356f8a2: Added a new config flag for customizing
isTypeOfandresolveTypeprefix (internalResolversPrefix)
Patch Changes
- Updated dependencies [8356f8a2]
- Updated dependencies [1d6a593f]
- @graphql-codegen/visitor-plugin-common@1.17.21
- @graphql-codegen/typescript@1.19.0
1.17.12
Patch Changes
- 1183d173: Bump all packages to resolve issues with shared dependencies
- Updated dependencies [1183d173]
- @graphql-codegen/visitor-plugin-common@1.17.20
- @graphql-codegen/typescript@1.18.1
- @graphql-codegen/plugin-helpers@1.18.2
1.17.11
Patch Changes
- faa13973: Fixed issues with mappers setup
- Updated dependencies [faa13973]
- @graphql-codegen/visitor-plugin-common@1.17.18
1.17.10
Patch Changes
- d2cde3d5: fixed isTypeOf resolvers signature
- 89a6aa80: Fixes issues with typesSuffix and arguments type name
- Updated dependencies [d2cde3d5]
- Updated dependencies [89a6aa80]
- Updated dependencies [f603b8f8]
- Updated dependencies [7ad7a1ae]
- Updated dependencies [da8bdd17]
- @graphql-codegen/visitor-plugin-common@1.17.15
- @graphql-codegen/typescript@1.17.10
- @graphql-codegen/plugin-helpers@1.17.9
1.17.9
Patch Changes
- ed7f6b97: Fix issues with mappers not being applied for interfaces or unions
1.17.8
Patch Changes
- 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
- af3803b8: only transform federated parent types when they contain @external directive
- Updated dependencies [1d7c6432]
- Updated dependencies [1d7c6432]
- @graphql-codegen/visitor-plugin-common@1.17.13
- @graphql-codegen/plugin-helpers@1.17.8
- @graphql-codegen/typescript@1.17.8