dotansimha/graphql-code-generator-community

[C# Operations] - add support for aliases

Open

#114 aperta il 15 feb 2021

Vedi su GitHub
 (1 commento) (2 reazioni) (0 assegnatari)TypeScript (195 fork)github user discovery
help wanted

Metriche repository

Star
 (136 star)
Metriche merge PR
 (Metriche PR in attesa)

Descrizione

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

Guida contributor