eddeee888 / graphql-code-generator-plugins

List of GraphQL Code Generator plugins that complements the official plugins.
MIT License
44 stars 10 forks source link

[FEAT]Mapper supports interface extends #223

Closed kgtkr closed 2 months ago

kgtkr commented 5 months ago

Is your feature request related to a problem? Please describe. Currently mapper does not recognize extended fields in interface

# schema.graphql
type Test {
  id: ID!
  name: String!
  description: String!
}
// schema.mappers.ts
interface Base {
  description: string;
}

export interface TestMapper extends Base {
  id: string;
  name: string;
}
// Test.ts
import type   { TestResolvers } from './../../types.generated';
    export const Test: TestResolvers = {
    /* Implement Test resolver logic here */
        description: () => { /* Test.description resolver is required because Test.description exists but TestMapper.description does not */ }
    };

Describe the solution you'd like Support interface extends.

Describe alternatives you've considered Use class extends instead of interface.

class Base {
  description!: string;
}

export class TestMapper extends Base {
  id!: string;
  name!: string;
}

Additional context

eddeee888 commented 3 months ago

Hi @kgtkr !

Thanks for reporting this issue. Here's the PR for the fix: https://github.com/eddeee888/graphql-code-generator-plugins/pull/242

Could you try the alpha version to see if it fixes your issue, please? 🙏

yarn add -ED @eddeee888/gcg-typescript-resolver-files@pr242-run423-1
kgtkr commented 3 months ago

@eddeee888 thanks for the great patch I can confirm that the issue is fixed in my project

eddeee888 commented 2 months ago

This is now available in v0.7.4. Thank you!