Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enumValues defined as objects create a null ResolverType in @graphql-codegen/visitor-plugin-common 5.6.0 #10204

Open
jamessharp opened this issue Nov 26, 2024 · 0 comments

Comments

@jamessharp
Copy link

Which packages are impacted by your issue?

@graphql-codegen/visitor-plugin-common

Describe the bug

Using config for enums like:

enumValues: {
  ReviewStatus: {
    {
      PREVIEW: 'preview',
      FULL: 'full',
      DISCARDED: 'discarded',
    }
  }
}

generates a resolver type for the enum of type null. E.g.

// ...
export type ResolverTypes = {
 // ...
 ReviewStatus: null;
  // ...
}

I suspect this commit is the culprit and that the logic should probably be something like

const isExternalFile = !!this.config.enumValues[typeName].sourceFile;
prev[typeName] = isExternalFile
  ? this.convertName(this.config.enumValues[typeName].typeIdentifier, {
    useTypesPrefix: false,
    useTypesSuffix: false,
  })
  : (this.config.enumValues[typeName].sourceIdentifier || this.convertName(this.config.enumValues[typeName].typeIdentifier));

Your Example Website or App

none

Steps to Reproduce the Bug or Issue

See description above

Expected behavior

The enum resolverType should be the enum, and not null.

Screenshots or Videos

No response

Platform

  • OS: macOS
  • NodeJS: 22
  • @graphql-codegen/visitor-plugin-common version(s): 5.6.0

Codegen Config File

No response

Additional context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant