dotansimha / dotansimha/graphql-code-generator-community

[C# Operations] - add support for aliases

Open
#114 1 comment 2 reactions 0 assignees View on GitHub
help wanted
Dominant language
TypeScript
Stars
137
Forks
195
Avg merge
6h 20m
Merged PRs (30d)
16

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).

1. My GraphQL schema:

```graphql
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!
}
```

2. My GraphQL operations:

```graphql
query allUsers {
users: users(role: USER) {
...UserFields
}
admins: users(role: ADMIN) {
...UserFields
}
}

fragment UserFields on User {
id
username
}
```

3. My `codegen.yml` config file:

```yml
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**

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.