aws-amplify / amplify-codegen

Amplify Codegen is a JavaScript toolkit library for frontend and mobile developers building Amplify applications.
Apache License 2.0
59 stars 59 forks source link

Adding a required "simple" data type return type on a graphql query makes codegen produce invalid typescript code #348

Open hisham opened 2 years ago

hisham commented 2 years ago

Before opening, please confirm:

How did you install the Amplify CLI?

npm

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

14.15.3

Amplify CLI Version

7.6.5

What operating system are you using?

mac

Amplify Categories

api

Amplify Commands

codegen

Describe the bug

Try this graphql query

  updateDate(
    newDate: AWSDateTime!
  ): AWSDateTime!
    @function(name: "MyGraphQLResolverFn-${env}")

The typescript codegen code produced will be:

  async UpdateDate(
    newDate: string
  ): Promise<UpdateDateQuery>

But the type UpdateDateQuery won't be defined in API.service.ts

If I remove the exclamation mark in the AWSDateTime return type, then return type is accurately Promise<string | null>. So why can't I get it to return Promise<string>?

Expected behavior

generated code should return Promise<string>

Reproduction steps

See above description

GraphQL schema(s)

See above

Log output

``` # Put your logs below this line ```

Additional information

No response

mohammedsahl commented 1 week ago

Hey 👋 just wondering if there are any updates on this?