dgs-codegen icon indicating copy to clipboard operation
dgs-codegen copied to clipboard

feature: Prefix type names

Open jord1e opened this issue 3 years ago • 6 comments

For example, given the schema:

interface A {
  id: ID!
}

type B implements A {
  id: ID!
  b: String!
}

With a prefix of GQL_, would generate:

  • interface GQL_A
  • class GQL_B implements GQL_A

This would help when converting between database, RPC, and GraphQL objects sharing the same name for example

I know #21 and #132 exist, would a PR in the (distant) future be OK?

jord1e avatar Feb 06 '22 19:02 jord1e

Thanks @jord1e. Yes, a PR would very much be welcome and appreciated! Now that we have seen a few requests for this feature, it makes sense to add that functionality. Internally, we don't have a use case for this and hence haven't quite prioritized this. But we do welcome any additional support and help from the community.

srinivasankavitha avatar Feb 21 '22 01:02 srinivasankavitha

This is a duplicate of another feature request to add suffixes.: https://github.com/Netflix/dgs-codegen/issues/389

srinivasankavitha avatar Sep 08 '22 23:09 srinivasankavitha

@srinivasankavitha hey! I would like to work on this issue, can you please confirm whether to have them as prefix or suffix?

vj-codes avatar Jan 23 '23 18:01 vj-codes

Thanks for reaching out. As requested, a prefix setting would be great.

srinivasankavitha avatar Jan 23 '23 18:01 srinivasankavitha

Just to confirm: I currently have not made any progress on this and have no plan to do it in the "near" future.

So good luck @vj-codes

jord1e avatar Jan 23 '23 18:01 jord1e

The reversal of this feature will also help. It would strip the prefix from the generated type.

For example, given the schema:

interface GQL_A {
  id: ID!
}

type GQL_B implements A {
  id: ID!
  b: String!
}

Without a prefix of GQL_, the plugin would generate:

interface A
class B implements A

This could be useful, when types are prefixed with namespace to avoid type conflicts when the schemas get merged into a federated supergraph.

ashpak-shaikh avatar May 04 '23 18:05 ashpak-shaikh