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

Extend rename transform to skip primitives #4684

Closed
dr3 opened this issue Oct 14, 2022 · 3 comments
Closed

Extend rename transform to skip primitives #4684

dr3 opened this issue Oct 14, 2022 · 3 comments

Comments

@dr3
Copy link
Contributor

dr3 commented Oct 14, 2022

Is your feature request related to a problem? Please describe.

When using a number of different data sources, its nice to have a consistent name pattern between types under 1 source. Sometimes this can be handled by the prefix transform, but often you may want slightly more specific control

Describe the solution you'd like

Along side config value useRegExpForTypes, have a skipPrimitives key.

This can either be true, to skip all or an array to define the exact primitives to skip when renaming.

Example

transforms:
      - rename:
          mode: bare
          renames:
            - from:
                type: (.*)
              to:
                type: Banana$1
              useRegExpForTypes: true
              skipPrimitives: false
      - prefix:
          mode: bare
          value: v1_
          includeRootOperations: true

Which would result in

type Query {
  v1_user: v1_BananaUserProfile
}

type v1_BananaUserProfile {
  id: String!
}

In this above case, using the prefix plugin alone with value: v1_Banana would result in query v1_Bananauser which we dont want

Describe alternatives you've considered

Adding more configurability to prefix transform, or a stand alone plugin. Both I think arnt as nice as this option in the rename plugin.

Additional context

@dr3 dr3 changed the title Extend rename transform to skip primatives Extend rename transform to skip primitives Oct 14, 2022
@santino
Copy link
Contributor

santino commented Oct 14, 2022

@ardatan, @gilgardosh, this sounds like a good enhancement to me.

Let us know your thoughts, I'd be happy to raise a PR if you are like this functionality.

@theguild-bot theguild-bot mentioned this issue Oct 14, 2022
@santino
Copy link
Contributor

santino commented Oct 17, 2022

Turned out the issue here was that wrap version of the transform had a bit more logic added to make sure default Scalar types are not renamed; but this was not applied to bare mode. This behaviour is applied by default without config.

The PR below fixes these issues, hence this ticket can be closed:
#4693

@ardatan
Copy link
Owner

ardatan commented Oct 18, 2022

Available in the latest release!

@ardatan ardatan closed this as completed Oct 18, 2022
@theguild-bot theguild-bot mentioned this issue Sep 28, 2023
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

3 participants