dotansimha/graphql-code-generator-community

[C# Operations] - add support for aliases

Open

#114 opened on 2021年2月15日

GitHub で見る
 (1 comment) (2 reactions) (0 assignees)TypeScript (195 forks)github user discovery
help wanted

Repository metrics

Stars
 (136 stars)
PR merge metrics
 (PR metrics pending)

説明

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

コントリビューターガイド