dotansimha/graphql-code-generator-community

[C# Operations] - add support for aliases

Open

#114 aberto em 15 de fev. de 2021

Ver no GitHub
 (1 comment) (2 reactions) (0 assignees)TypeScript (195 forks)github user discovery
help wanted

Métricas do repositório

Stars
 (136 stars)
Métricas de merge de PR
 (Métricas PR pendentes)

Description

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

Guia do colaborador