Skip to content

graphql-modules-preset requires __isTypeOf #10438

@mzl-md

Description

@mzl-md

Which packages are impacted by your issue?

@graphql-codegen/graphql-modules-preset

Describe the bug

Problem

After updating the codegen libs, our typescript typecheck fails with Property '__isTypeOf' is missing in type

Package Change
@graphql-codegen/cli (source) 5.0.7 -> 6.0.0
@graphql-codegen/graphql-modules-preset (source) 4.0.17 -> 5.0.0
@graphql-codegen/typescript (source) 4.1.6 -> 5.0.0
@graphql-codegen/typescript-resolvers (source) 4.5.2 -> 5.0.0

Workaround

When we add __isTypeOf: undefined to the object instances, it works again.

Suspected Problem

typescript-resolvers now generates resolver types without __isTypeOf instead of optional, but graphql-modules-preset still generates the type Pick<Types.MyTypeResolvers, DefinedFields['MyType'] | '__isTypeOf'>. So the module types now require a __isTypeOf: any attribute.

Your Example Website or App

none

Steps to Reproduce the Bug or Issue

  1. Generate types for any schema with a query using the given dependencies

Expected behavior

As a user I expect the generated module types to not include __isTypeOf anymore if they are not part of the generated resolver types.

Screenshots or Videos

No response

Platform

  • OS: macOS
  • NodeJS: v20.19.5
  • graphql version: 16.11.0
  • @graphql-codegen/* version(s): 5.0.0 (see description)

Codegen Config File

import type {CodegenConfig} from '@graphql-codegen/cli'

const config: CodegenConfig = {
generates: {
'./src/schema/': {
config: {
avoidOptionals: true,
inputMaybeValue: 'T | null | undefined',
makeResolverTypeCallable: true,
mappers: {},
maybeValue: 'T | null | undefined',
optionalInfoArgument: true,
optionalResolveType: true,
useIndexSignature: true
},
plugins: [
{
add: {
content: '/* eslint-disable */'
}
},
'typescript',
'typescript-resolvers'
],
preset: 'graphql-modules',
presetConfig: {
baseTypesPath: '../generated-types/graphql.ts',
filename: 'generated-module-types.ts',
useGraphQLModules: false
}
}
},
schema: 'src/schema/**/schema.graphql'
}

export default config

Additional context

No response

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions