dotansimha/graphql-code-generator-community

[C# Operations] - add support for aliases

Open

#114 创建于 2021年2月15日

在 GitHub 查看
 (1 评论) (2 反应) (0 负责人)TypeScript (195 fork)github user discovery
help wanted

仓库指标

Star
 (136 star)
PR 合并指标
 (PR 指标待抓取)

描述

Describe the bug For now generator use "type" to produce output property name. It should use alias instead.

To Reproduce

  1. Generate attached operations.

  2. See generated output - it generates 2 properties ("users") with the same name (C# syntax error).

  3. My GraphQL schema:

scalar Date

schema {
  query: Query
}

type Query {
  users(role: Role!): [User]
}

enum Role {
  USER,
  ADMIN,
}

union SearchResult = User

type User {
  id: ID!
  username: String!
  email: String!
  role: Role!
}
  1. My GraphQL operations:
query allUsers {
  users: users(role: USER) {
    ...UserFields
  }
  admins: users(role: ADMIN) {
    ...UserFields
  }
}

fragment UserFields on User {
  id
  username
}
  1. My codegen.yml config file:
generates:
  src/main/c-sharp/my-org/my-app/Operations.cs:
    plugins:
      - c-sharp-operations
    config:
      typesafeOperation: true

Expected behavior

  1. public System.Collections.Generic.List users { get; set; }
  2. public System.Collections.Generic.List admins { get; set; } In generated output.

Environment:

  • @graphql-codegen/c-sharp-operations:

Additional context

贡献者指南