dotansimha / graphql-code-generator

A tool for generating code based on a GraphQL schema and GraphQL operations (query/mutation/subscription), with flexible support for custom plugins.
https://the-guild.dev/graphql/codegen/
MIT License
10.86k stars 1.33k forks source link

Interfaces forcing c# 8.0, is this intended? #5600

Open magnusottosson opened 3 years ago

magnusottosson commented 3 years ago

Describe the bug When we have an interface in the graphl schema the generated c# interface properties will have a public prefix making them a c# 8.0 feature.

Schema

interface Product {
  articles: [Article!]!
}

C#

public interface Product {
      [JsonProperty("articles")]
      public List<Article> articles { get; set; }
}

I guess the publicpart here should probably be omitted? Or is this intended?

  1. My GraphQL schema:
# Put your schema here
  1. My GraphQL operations:
# Put your operations here
  1. My codegen.yml config file:
overwrite: true
schema: "https://somedomain/graphql"
documents: "./src/graphql/**/*.graphql"
generates:
  ./src/GraphQL/Client/GraphQLClientServices.generated.cs:
    config:
      namespaceName: SomeNameSpace
      typesafeOperation: false
    plugins:
      - c-sharp
      - c-sharp-operations

Expected behavior I expect the output to not include the public part.

Environment:

dotansimha commented 3 years ago

Hi @magnusottosson , Thank you for reporting this. We are not highly familiar with the C# plugins. I can refer you to https://github.com/dotansimha/graphql-code-generator/pull/3881 where this plugin was modified recently. I think the goal here was to allow to provide a similar experience to TS/JS. If you think this should be implemented differently, please feel free to send a PR :)