Skip to content

'graphql-modules' preset fails to generate interface resolver types #10518

@gilgardosh

Description

@gilgardosh

Which packages are impacted by your issue?

@graphql-codegen/typescript-resolvers

Describe the bug

The generated interface resolver base type includes only __resolveType attribute.

This behavior has a couple of problems:

  1. The resolver type derived from the base type is broken: type ParentInterfaceResolvers = Pick<Types.ParentInterfaceResolvers, DefinedFields['ParentInterface']>;, as Types.ParentInterfaceResolvers got no shared attributes with DefinedFields['ParentInterface']
  2. Cases where user wishes to create common resolvers shared by the types implementing the interface left unanswered, as ParentInterfaceResolvers is unusable and type-based resolvers usually has unshared attributes

Your Example Website or App

#10519

Steps to Reproduce the Bug or Issue

Set codegen to modules preset with 'typescript-resolvers- plugin. Then feed it with a simple schema which includes interface:

interface Plant {
  id: ID!
  species: String!
}

type Flower implements Plant {
  id: ID!
  species: String!
  color: String!
}

type Tree implements Plant {
  id: ID!
  species: String!
  height: Float!
}

Expected behavior

The interface resolver type will include all of it's shared attributes

Screenshots or Videos

No response

Platform

  • OS: [e.g. macOS, Windows, Linux]
  • NodeJS: [e.g. 18.5.0]
  • graphql version: [e.g. 16.3.0]
  • @graphql-codegen/* version(s): [e.g. 2.6.2]

Codegen Config File

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions