aws-amplify / aws-amplify/amplify-codegen

DX: Inconsistent casing of "ID" in generated graphql queries

Open
#350 3 comments 0 reactions 0 assignees View on GitHub
feature-request p4
Dominant language
TypeScript
Stars
59
Forks
64
PR merge metrics
No merged PRs in 30d

Description

### Before opening, please confirm:

- [X] I have installed the latest version of the Amplify CLI (see above), and confirmed that the issue still persists.
- [X] I have [searched for duplicate or closed issues](https://github.com/aws-amplify/amplify-cli/issues?q=is%3Aissue+).
- [X] I have read the guide for [submitting bug reports](https://github.com/aws-amplify/amplify-cli/blob/master/CONTRIBUTING.md#bug-reports).
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.

### How did you install the Amplify CLI?

_No response_

### If applicable, what version of Node.js are you using?

_No response_

### Amplify CLI Version

7.6.5

### What operating system are you using?

Windows

### Amplify Categories

api

### Amplify Commands

codegen

### Describe the bug

I've been trying to keep everything standardised when it comes to the capitalisation of my "ID" fields. I've used the same format that is used in the schema through out yet it seems that some of the auto generated queries for graphql aren't sticking to that consistently.

Here I have my schema which has a @key with a queryField of "visitsByAreaIDAndStatus":

![image](https://user-images.githubusercontent.com/1674590/147968846-928cece8-64f0-4ff3-92a2-e42f47aa8fd2.png)

Note that "ID" matches that uses for the ID Type too.

Now in my generated queries we have this:

![image](https://user-images.githubusercontent.com/1674590/147968628-21fc4fcb-b4a1-4e59-b421-13e9dd59535d.png)

The variable name for this query is "visitsByAreaIdAndStatus" yet the query itself uses the correct casing. This leads to me having to keep looking it up in AppSync console to make sure I'm using the right casing. Its a seemingly small thing but it messed up my flow enough today to want to make this issue for it :)

### Expected behavior

I'm guessing there is a titleCase method that the queries are using to make them standardised, could this not be tweaked or give us an opt in to have some over-rides or exceptions? Ideally I like it to match the casing used schema which is provided to it via the queryField, could it not just use that if provided?

### Reproduction steps

Create a schema, give one of your models a key with a queryField of "myTypeByID", generate it, check the generated queries in `src\graphql\queries.ts`

### GraphQL schema(s)

```graphql
# Put schemas below this line

```

### Log output

```
# Put your logs below this line

```

### Additional information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.