eddeee888 / graphql-code-generator-plugins

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

Improve interface mapper logic to recursively pick all properties #242

Closed eddeee888 closed 3 months ago

eddeee888 commented 3 months ago

We were previously only pick the properties of a mapper interface declaration.

However, we need to recursively pick all the properties to have the right fields, otherwise we'd miss the properties of the base interfaces.

For example:

interface BaseNode {
  id: string
}

interface NodeIndentifier {
  fullName: string;
}

interface Pet extends BaseNode, NodeIndentifier {
  age: number;
}

export interface CatMapper extends Pet {
  scratches: boolean;
}

export interface DogMapper extends Pet {
  likesToDig: boolean;
}

Then, the collected node properties would look like this:

Mapper Previous Now
CatMapper { scratches: boolean } { id: string; fullName: string; age: number; scratches: boolean}
DogMapper { likesToDig: boolean } { id: string; fullName: string; age: number; likesToDig: boolean}

Detecting mapper properties correctly allows downstream field resolver checkers and generation to work correctly. Issue: https://github.com/eddeee888/graphql-code-generator-plugins/issues/223

changeset-bot[bot] commented 3 months ago

🦋 Changeset detected

Latest commit: 507b939a032ada2dcfdecbf5eb6df1ab453a3fbe

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package | Name | Type | | ---------------------------------------- | ----- | | @eddeee888/gcg-typescript-resolver-files | Patch |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

eddeee888 commented 3 months ago

/release-snapshot

github-actions[bot] commented 3 months ago

✅ Successfully published package/s with tag pr242-run423-1!