eddeee888 / graphql-code-generator-plugins

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

[BUG] regression on version >= 0.9.3, scalarsOverrides ignores custom export name in resolver path. #306

Closed feychenie closed 1 month ago

feychenie commented 3 months ago

Describe the bug After upgrading from 0.9.2 to 0.9.3 (and tested on 0.9.4 as well), the lookup for an exported custom scalar ignores the custom export name after the # in the file path.

scalarsOverrides: { Date: { resolver: './base/resolvers/Date#DateResolver', type: 'string' }, } behaves as if the path was actually ./base/resolvers/Date#Date, #DateResolver is ignored.

This was working perfectly fine before.

To Reproduce

  1. Create a Date scalar resolver in a Date.ts file, and export the resolver as export const DateResolver instead of export const Date
  2. add the corresponding scalar override Date: { resolver: './Date#DateResolver', type: 'string' }
  3. launch generation 4.notice that an additional export cost Date scalar scaffold has been added to the file.

Expected behavior

Nothing should happen as the custom scalar is already exported

Versions

eddeee888 commented 3 months ago

Thanks @feychenie , I'll take a look

eddeee888 commented 2 months ago

Hi @feychenie ,

Thanks for the issue report, I'm able to replicate and fix it. I've an alpha version that could fix this issue:

yarn add -D @eddeee888/gcg-typescript-resolver-files@pr320-run582-1

For posterity, any resolver overrides that are provided by the user will give full control to the user in terms of implementation and exports. There are currently externalResolvers (for non-scalars) and scalarsOverrides (for scalars) options that allow users to do this 🙂

eddeee888 commented 1 month ago

This should be fixed in v0.10.4.